public function safetyUpload() { $ret = $this->upload(); if ($ret == "success") { if (nt_check) { $f = new FTP(FTP_URL, FTP_USER, UPLOAD_PASSWORD, UPLOAD_DIR); if ($f->status == 1) { $f->put($this->folder . $this->name, $this->name); $i = 0; $has = false; while ($i < UPLOAD_TRY_TIME) { sleep(UPLOAD_TRY_INTERVAL); if ($f->isFile($this->name)) { $has = true; //echo $f->unlink($this->name); } $i++; } $f->bye(); if ($has) { return "success"; } else { return "not saft"; } } else { unlink($this->folder . $this->name); return "ftp_unconnect"; } } else { return $ret; } } else { return $ret; } }
public function delete($blnRemovePhysical = FALSE) { self::$object = "ElementFieldBigText"; self::$table = "pcms_element_field_bigtext"; if ($blnRemovePhysical) { //*** Get TemplateField. $objElementField = ElementField::selectByPk($this->fieldId); if (is_object($objElementField)) { $objTemplateField = TemplateField::selectByPk($objElementField->getTemplateFieldId()); switch ($objTemplateField->getTypeId()) { case FIELD_TYPE_FILE: case FIELD_TYPE_IMAGE: //*** Get remote settings. $strServer = Setting::getValueByName('ftp_server'); $strUsername = Setting::getValueByName('ftp_username'); $strPassword = Setting::getValueByName('ftp_password'); $strRemoteFolder = Setting::getValueByName('ftp_remote_folder'); //*** Remove deleted files. $objFtp = new FTP($strServer); $objFtp->login($strUsername, $strPassword); $objFtp->pasv(TRUE); $arrValues = explode("\n", $this->value); foreach ($arrValues as $value) { if (!empty($value)) { //*** Find file name. $arrFile = explode(":", $value); if (count($arrFile) > 1) { //*** Check if the file is used by other elements. if (!ElementField::fileHasDuplicates($value, 1)) { //*** Remove files. $strFile = $strRemoteFolder . $arrFile[1]; $objFtp->delete($strFile); if ($objTemplateField->getTypeId() == FIELD_TYPE_IMAGE) { //*** Remove template settings files. $objImageField = new ImageField($objElementField->getTemplateFieldId()); $arrSettings = $objImageField->getSettings(); foreach ($arrSettings as $key => $arrSetting) { if (!empty($arrSetting['width']) || !empty($arrSetting['height'])) { //*** Remove file. $strFile = $strRemoteFolder . FileIO::add2Base($arrFile[1], $arrSetting['key']); $objFtp->delete($strFile); } } } } } } } break; } } } return parent::delete(); }
/** * (non-PHPdoc) * @see \mithra62\Validate\RuleInterface::validate() * @ignore */ public function validate($field, $input, array $params = array()) { try { if ($input == '' || empty($params['0'])) { return false; } $params = $params['0']; if (empty($params['ftp_hostname']) || empty($params['ftp_password']) || empty($params['ftp_username']) || empty($params['ftp_port']) || empty($params['ftp_store_location'])) { return false; } $local = new Remote(new Local(dirname($this->getTestFilePath()))); $filesystem = new Remote(FTP::getRemoteClient($params)); if ($local->has($this->test_file)) { $contents = $local->read($this->test_file); $filesystem->getAdapter()->setRoot($params['ftp_store_location']); if ($filesystem->has($this->test_file)) { $filesystem->delete($this->test_file); } else { if ($filesystem->write($this->test_file, $contents)) { $filesystem->delete($this->test_file); } } } $filesystem->getAdapter()->disconnect(); return true; } catch (\Exception $e) { return false; } }
/** * @param string $ftp_dsn ftp://user:pass@localhost/ */ public function __construct($ftp_dsn) { $ftp = FTP::parse_dsn($ftp_dsn); foreach ($ftp as $k => $v) { $this->{$k} = $v; } }
public function delete() { global $_CONF; parent::$object = "StorageItem"; parent::$table = "pcms_storage_item"; if (class_exists("AuditLog")) { AuditLog::addLog(AUDIT_TYPE_STORAGE, $this->getId(), $this->getName(), "delete"); } //*** Remove child items. $objElements = $this->getItems(); foreach ($objElements as $objElement) { $objElement->delete(); } if ($this->getTypeId() == STORAGE_TYPE_FILE) { $strValue = $this->getData()->getLocalName(); if (!empty($strValue)) { //*** Remove physical. $strServer = Setting::getValueByName('ftp_server'); $strUsername = Setting::getValueByName('ftp_username'); $strPassword = Setting::getValueByName('ftp_password'); $strRemoteFolder = Setting::getValueByName('ftp_remote_folder'); //*** Remove deleted files. $objFtp = new FTP($strServer); $objFtp->login($strUsername, $strPassword); $objFtp->pasv(TRUE); $strFile = $strRemoteFolder . $strValue; $objFtp->delete($strFile); } $objElements = $this->getLinkedElementFields(); foreach ($objElements as $objElement) { $strValue = $objElement->getValue(); $arrValue = explode("\n", $strValue); $arrNew = array(); foreach ($arrValue as $value) { $arrFile = explode(":", $value); if (count($arrFile) > 2 && $arrFile[2] == $this->id) { //*** Skip me. } else { array_push($arrNew, $value); } } $objElement->setValue(implode("\n", $arrNew)); $objElement->save(); } } return parent::delete($_CONF['app']['account']->getId()); }
/** * Singleton to instantiate the class * * @return mixed Object of the class */ public static function getInstance() { if (self::$instance === NULL) { $klasse = __CLASS__; self::$instance = new $klasse(); } return self::$instance; }
/** * Display a listing of the resource. * * @return Response */ public function index() { $status = FTP::connection()->makeDir('/laravel'); $status = FTP::connection()->makeDir('/laravel/newdir'); $status = FTP::connection()->makeDir('/laravel/newdir2'); $listing = FTP::connection()->getDirListing('/laravel'); dd($listing); }
/** * 连接ftp * * $ftp = 'ftp://*****:*****@192.168.99.1:21' * @param string $ftp ftp连接url * @return boolean */ function ftp_connect_v2($ftp) { if (!preg_match('/^ftp:\\/\\/[^:]+:[^@]+@[\\d\\.]+(:\\d+)?$/i', $ftp) || !($ftp = parse_url($ftp))) { return false; } elseif (@$ftp['scheme'] != 'ftp') { return false; } elseif (empty($ftp['host'])) { return false; } else { $ftp += array('port' => 21, 'user' => '', 'pass' => ''); } $fp = FTP::instance($ftp['host'], $ftp['port'], $ftp['user'], $ftp['pass']); if (!$fp->connect()) { return $fp->error(); } return $fp; }
/** * (non-PHPdoc) * @see \mithra62\Validate\RuleInterface::validate() * @ignore */ public function validate($field, $input, array $params = array()) { try { if ($input == '' || empty($params['0'])) { return false; } $params = $params['0']; if (empty($params['ftp_hostname']) || empty($params['ftp_password']) || empty($params['ftp_username']) || empty($params['ftp_port'])) { return false; } $filesystem = new Remote(FTP::getRemoteClient($params)); if (!$filesystem->getAdapter()->listContents()) { return false; } $filesystem->getAdapter()->disconnect(); return true; } catch (\Exception $e) { return false; } }
/** * rawlist * * @param string $dir * @return array */ private function _rawlist($dir = '/') { self::$_dir = $dir = str_replace('\\', '/', $dir); if (isset(self::$_rawlist[self::$_dir])) { return self::$_rawlist[self::$_dir]; } elseif (isset(self::$_rawlist[self::$_dir . '/'])) { return self::$_rawlist[self::$_dir . '/']; } ftp_chdir($this->_res, '/'); if (preg_match('/^[A-Z]+?:[\\*|\\/*]+(.*)/', $dir, $match)) { $dir = $match[1] ? '/' . $match[1] : '/'; } foreach ((array) ftp_rawlist($this->_res, '-A /' . IOWrapper::set($dir)) as $var) { if (mb_substr($var, -3) == ' ..') { continue; } else { preg_replace_callback('`^(d|l|\\-{1}+)(.{9}+)\\s*(?:\\d{1,3})\\s*(\\d+?|\\w+?)\\s*(\\d+?|\\w+?)\\s*(\\d*)\\s([a-zA-Z]{3}+)\\s*([0-9]{1,2}+)\\s*([0-9]{2}+):?([0-9]{2}+)\\s*(.*)$`U', array($this, '_rawlistCallback'), $var); } } self::$_rawlist[self::$_dir]['.'] = array('chmod' => '0', 'uid' => '', 'owner' => '', 'gid' => '', 'group' => '', 'size' => '0', 'mtime' => '', 'file' => '.', 'type' => 'dir'); return self::$_rawlist[self::$_dir]; }
* Créer des éléments sur le FTP (dossier, fichier) */ // Includes require_once 'ftp.class.php'; // Variables $out = array(); if (isset($_POST['path'])) { $path = htmlspecialchars($_POST['path']); } else { $path = null; } if (isset($_POST['dir'])) { $dir = htmlspecialchars($_POST['dir']); } else { $dir = null; } if (isset($_POST['file'])) { $file = htmlspecialchars($_POST['file']); } else { $file = null; } // Dossier if ($path && $dir) { $out = FTP::createNewFolder($path, strtolower($dir)); } // Fichier if ($path && $file) { $out = FTP::createNewFile($path, $file); } // Retour echo json_encode($out);
function ShowUpdatePage() { global $LNG, $CONF, $db; $Patchlevel = explode(".", VERSION); if ($_REQUEST['action'] == 'history') { $Level = 0; } elseif (isset($Patchlevel[2])) { $Level = $Patchlevel[2]; } else { $Level = 1159; } $opts = array('http' => array('method' => "GET", 'header' => "Patchlevel: " . $Level . "\r\nUser-Agent: 2Moons Update API (Rev " . $Patchlevel[2] . ")\r\n")); $context = stream_context_create($opts); switch ($_REQUEST['action']) { case "download": require_once ROOT_PATH . 'includes/libs/zip/zip.lib.' . PHP_EXT; $UpdateArray = unserialize(file_get_contents("http://update.2moons-systems.com/index.php?action=getupdate", FALSE, $context)); if (!is_array($UpdateArray['revs'])) { exitupdate(array('debug' => array('noupdate' => "Kein Update vorhanden!"))); } $SVN_ROOT = $UpdateArray['info']['svn']; $zipfile = new zipfile(); $TodoDelete = ""; foreach ($UpdateArray['revs'] as $Rev => $RevInfo) { if (!empty($RevInfo['add'])) { foreach ($RevInfo['add'] as $File) { if (strpos($File, '.') !== false) { $zipfile->addFile(file_get_contents($SVN_ROOT . $File), str_replace("/trunk/", "", $File), $RevInfo['timestamp']); } } } if (!empty($RevInfo['edit'])) { foreach ($RevInfo['edit'] as $File) { if (strpos($File, '.') !== false) { $zipfile->addFile(file_get_contents($SVN_ROOT . $File), str_replace("/trunk/", "", $File), $RevInfo['timestamp']); } } } if (!empty($RevInfo['del'])) { foreach ($RevInfo['del'] as $File) { if (strpos($File, '.') !== false) { $TodoDelete .= str_replace("/trunk/", "", $File) . "\r\n"; } } } $LastRev = $Rev; } if (!empty($TodoDelete)) { $zipfile->addFile($TodoDelete, "!TodoDelete!.txt", $RevInfo['timestamp']); } update_config('VERSION', str_replace("RC", "", $Patchlevel[0]) . "." . $Patchlevel[1] . "." . $LastRev); // Header für Download senden header("HTTP/1.1 200 OK"); header("Content-Type: application/force-download"); header('Content-Disposition: attachment; filename="patch_' . $Level . '_to_' . $LastRev . '.zip"'); header("Content-Transfer-Encoding: binary"); // Zip File senden echo $zipfile->file(); exit; break; case "update": require_once ROOT_PATH . 'includes/libs/ftp/ftp.class.' . PHP_EXT; require_once ROOT_PATH . 'includes/libs/ftp/ftpexception.class.' . PHP_EXT; $UpdateArray = unserialize(file_get_contents("http://update.2moons-systems.com/index.php?action=getupdate", FALSE, $context)); if (!is_array($UpdateArray['revs'])) { exitupdate(array('debug' => array('noupdate' => "Kein Update vorhanden!"))); } $SVN_ROOT = $UpdateArray['info']['svn']; $CONFIG = array("host" => $CONF['ftp_server'], "username" => $CONF['ftp_user_name'], "password" => $CONF['ftp_user_pass'], "port" => 21); try { $ftp = FTP::getInstance(); $ftp->connect($CONFIG); $LOG['debug']['connect'] = "FTP-Verbindungsaufbau: OK!"; } catch (FTPException $error) { $LOG['debug']['connect'] = "FTP-Verbindungsaufbau: ERROR! " . $error->getMessage(); exitupdate($LOG); } if ($ftp->changeDir($CONF['ftp_root_path'])) { $LOG['debug']['chdir'] = "FTP-Changedir(" . $CONF['ftp_root_path'] . "): OK!"; } else { $LOG['debug']['chdir'] = "FTP-Changedir(" . $CONF['ftp_root_path'] . "): ERROR! Pfad nicht gefunden!"; exitupdate($LOG); } foreach ($UpdateArray['revs'] as $Rev => $RevInfo) { if (!empty($RevInfo['add'])) { foreach ($RevInfo['add'] as $File) { if ($File == "/trunk/updates/update_" . $Rev . ".sql") { $db->multi_query(str_replace("prefix_", DB_PREFIX, file_get_contents($SVN_ROOT . $File))); continue; } elseif ($File == "/trunk/updates/update_" . $Rev . ".php") { require $SVN_ROOT . $File; } else { if (strpos($File, '.') !== false) { $Data = fopen($SVN_ROOT . $File, "r"); if ($ftp->uploadFromFile($Data, str_replace("/trunk/", "", $File))) { $LOG['update'][$Rev][$File] = "OK! - Updated"; } else { $LOG['update'][$Rev][$File] = "ERROR! - Konnte Datei nicht hochladen"; } fclose($Data); } else { if ($ftp->makeDir(str_replace("/trunk/", "", $File), 1)) { if (PHP_SAPI == 'apache2handler') { $ftp->chmod(str_replace("/trunk/", "", $File), '0777'); } else { $ftp->chmod(str_replace("/trunk/", "", $File), '0755'); } $LOG['update'][$Rev][$File] = "OK! - Updated"; } else { $LOG['update'][$Rev][$File] = "ERROR! - Konnte Datei nicht hochladen"; } } } } } if (!empty($RevInfo['edit'])) { foreach ($RevInfo['edit'] as $File) { if (strpos($File, '.') !== false) { if ($File == "/trunk/updates/update_" . $Rev . ".sql") { $db->multi_query(str_replace("prefix_", DB_PREFIX, file_get_contents($SVN_ROOT . $File))); continue; } else { $Data = fopen($SVN_ROOT . $File, "r"); if ($ftp->uploadFromFile($Data, str_replace("/trunk/", "", $File))) { $LOG['update'][$Rev][$File] = "OK! - Updated"; } else { $LOG['update'][$Rev][$File] = "ERROR! - Konnte Datei nicht hochladen"; } fclose($Data); } } } } if (!empty($RevInfo['del'])) { foreach ($RevInfo['del'] as $File) { if (strpos($File, '.') !== false) { if ($ftp->delete(str_replace("/trunk/", "", $File))) { $LOG['update'][$Rev][$File] = "OK! - Gelöscht"; } else { $LOG['update'][$Rev][$File] = "ERROR! - Konnte Datei nicht löschen"; } } else { if ($ftp->removeDir(str_replace("/trunk/", "", $File), 1)) { $LOG['update'][$Rev][$File] = "OK! - Gelöscht"; } else { $LOG['update'][$Rev][$File] = "ERROR! - Konnte Datei nicht löschen"; } } } } $LastRev = $Rev; } $LOG['finish']['atrev'] = "UPDATE: OK! At Revision: " . $LastRev; // Verbindung schließen update_config('VERSION', str_replace("RC", "", $Patchlevel[0]) . "." . $Patchlevel[1] . "." . $LastRev); exitupdate($LOG); break; default: $template = new template(); $template->page_header(); $RevList = ''; $Update = ''; $Info = ''; if (!function_exists('file_get_contents') || !function_exists('fsockopen')) { $template->message('Function file_get_contents oder fsockopen deactive', false, 0, true); } elseif (($RAW = @file_get_contents("http://update.2moons-systems.com/index.php?action=update", FALSE, $context)) !== false) { $UpdateArray = unserialize($RAW); if (is_array($UpdateArray['revs'])) { foreach ($UpdateArray['revs'] as $Rev => $RevInfo) { if (!(empty($RevInfo['add']) && empty($RevInfo['edit'])) && $Patchlevel[2] < $Rev) { $Update = "<tr><th><a href=\"?page=update&action=update\">Update</a> - <a href=\"?page=update&action=download\">Download Patch Files</a></th></tr>"; $Info = "<tr><td class=\"c\" colspan=\"5\">Aktuelle Updates</td></tr>"; } $edit = ""; if (!empty($RevInfo['edit']) || is_array($RevInfo['edit'])) { foreach ($RevInfo['edit'] as $file) { $edit .= '<a href="http://code.google.com/p/2moons/source/diff?spec=svn' . $Rev . '&r=' . $Rev . '&format=side&path=' . $file . '" target="diff">' . str_replace("/trunk/", "", $file) . '</a><br>'; } } $RevList .= "<tr>\r\n\t\t\t\t\t\t" . ($Patchlevel[2] == $Rev ? "<td class=c colspan=5>Momentane Version</td></tr><tr>" : ($Patchlevel[2] - 1 == $Rev ? "<td class=c colspan=5>Alte Updates</td></tr><tr>" : "")) . "\r\n\t\t\t\t\t\t<td class=c >" . ($Patchlevel[2] == $Rev ? "<font color=\"red\">" : "") . "Revision " . $Rev . " " . date("d. M y H:i:s", $RevInfo['timestamp']) . " von " . $RevInfo['author'] . ($Patchlevel[2] == $Rev ? "</font>" : "") . "</td></tr>\r\n\t\t\t\t\t\t<tr><th>" . makebr($RevInfo['log']) . "</th></tr>\r\n\t\t\t\t\t\t" . (!empty($RevInfo['add']) ? "<tr><th>ADD:<br>" . str_replace("/trunk/", "", implode("<br>\n", $RevInfo['add'])) . "</b></th></tr>" : "") . "\r\n\t\t\t\t\t\t" . (!empty($RevInfo['edit']) ? "<tr><th>EDIT:<br>" . $edit . "</b></th></tr>" : "") . "\r\n\t\t\t\t\t\t" . (!empty($RevInfo['del']) ? "<tr><th>DEL:<br>" . str_replace("/trunk/", "", implode("<br>\n", $RevInfo['del'])) . "</b></th></tr>" : "") . "\r\n\t\t\t\t\t\t</tr>"; } } $template->assign_vars(array('RevList' => $RevList, 'Update' => $Update, 'Info' => $Info)); $template->show('adm/UpdatePage.tpl'); } else { $template->message('Update Server currently not available', false, 0, true); } break; } }
/** * Quick upload mthod for a single file. * * @param string $sourceFile local file name * @param array $ftpSettings (path.uploads, host, username, password) * @throws \RuntimeException */ public static function ftpUpload($sourceFile, $ftpSettings, $targetFile = null, $blnSecure = false) { $strFtpFileName = is_null($targetFile) ? basename($sourceFile) : $targetFile; $strFtpFileDir = $ftpSettings['path']['uploads']; $objFtp = new FTP($ftpSettings['host'], 21, 90, $blnSecure); $objRet = $objFtp->login($ftpSettings['username'], $ftpSettings['password']); if (!$objRet) { throw new \RuntimeException("Could not login to FTP server.", 404); } //*** Passive mode. $objFtp->pasv(true); //*** Create dealer folder. try { $objFtp->mksubdirs($strFtpFileDir); } catch (\Exception $ex) { //*** Ignore. The folder probably already exists. } //*** Transfer file. $objRet = $objFtp->nb_put($strFtpFileName, $sourceFile, FTP_BINARY); while ($objRet == FTP_MOREDATA) { // Continue uploading... $objRet = $objFtp->nb_continue(); } if ($objRet != FTP_FINISHED) { //*** Something went wrong. throw new \RuntimeException("FTP transfer of {$strFtpFileName} interruppted.", 500); } //*** Remove local file. if (file_exists($sourceFile)) { @unlink($sourceFile); } }
public function actionZoomf() { global $CONFIG; $feedName = "zoomf"; $strPath = $this->getFeedFolderPath($feedName); $command = Yii::app()->db->createCommand($this->getSQLStatement()); $dataReader = $command->query(); $RENDER = $this->getFeedHeader($dataReader); foreach ($dataReader as $row) { switch ($row['dea_branch']) { case 2: $intRMBranchID = 24869; break; case 4: $intRMBranchID = 24869; break; case 1: case 3: default: $intRMBranchID = 3120; break; } $postcode = explode(" ", $row["pro_postcode"]); $RENDER .= $intRMBranchID . "_" . $row["dea_id"] . "^"; //AGENT_REF $RENDER .= $row["pro_addr1"] . "^"; //ADDRESS_1 $RENDER .= $row["pro_addr3"] . "^"; //ADDRESS_2 $RENDER .= $row["are_title"] . "^"; //ADDRESS_3 $RENDER .= "^"; //ADDRESS_4 $RENDER .= $row["pro_addr5"] . "^"; //TOWN $RENDER .= $postcode[0] . "^"; //POSTCODE1 $RENDER .= $postcode[1] . "^"; //POSTCODE2 $RENDER .= "^"; //FEATURE1 property type $RENDER .= "^"; //FEATURE2 bedroms $RENDER .= "^"; //FEATURE3 ch $RENDER .= "^"; //FEATURE4 dg $RENDER .= "^"; //FEATURE5 $RENDER .= "^"; //FEATURE6 $RENDER .= "^"; //FEATURE7 $RENDER .= "^"; //FEATURE8 $RENDER .= "^"; //FEATURE9 $RENDER .= "^"; //FEATURE10 $length = 300 - strlen($row["dea_strapline"]); // 300 is allowed, but i add (cont) so we use 294 $desc = $this->htmlentitiesWithStripTag($row["dea_description"]); $trimmed = preg_replace("/[\r\n]+[\\s\t]*[\r\n]+/", "", $desc); $trimmed = str_replace("&#039;", "'", $trimmed); $trimmed = str_replace("&amp;#039;", "'", $trimmed); $trimmed = str_replace("&eacute;", "�", $trimmed); $trimmed = substr($trimmed, 0, $length); $RENDER .= $row["dea_strapline"] . ": " . $trimmed . "^"; //SUMMARY $longDescription = $row["dea_description"]; if ($row["total_area"]) { $longDescription .= "<p>Approximate Gross Internal Area: " . $row["total_area"] . " square metres</p>"; } $longDescription .= "<p>For further information or to arrange a viewing, please contact our <b>" . $row["bra_title"] . " Branch</b> on <b>" . $row["bra_tel"] . ".</b></p>"; $longDescription .= "<p>Visit <b>www.woosterstock.co.uk</b> for full details, colour photos, maps and floor plans.</p>"; $longDescription .= "<p>We endeavour to make all our property particulars, descriptions, floor-plans, marketing and local information accurate and reliable but we make no guarantees as to the accuracy of this information. All measurements and dimensions are for guidance only and should not be considered accurate. If there is any point which is of particular importance to you we advise that you contact us to confirm the details; particularly if you are contemplating travelling some distance to view the property. Please note that we have not tested any services or appliances mentioned in property sales details.</p>"; $RENDER .= preg_replace("/[\r\n]+[\\s\t]*[\r\n]+/", "", $longDescription) . "^"; //DESCRIPTION $RENDER .= $intRMBranchID . "^"; //BRANCH_ID // we have three possible sattusses : under Offer statuses returns 1; 0 otherwise $row["dea_status"] == 'Under Offer' || $row["dea_status"] == 'Under Offer with Other' ? $RENDER .= "1" . "^" : ($RENDER .= "0" . "^"); $RENDER .= $row["dea_bedroom"] . "^"; //BEDROOMS $RENDER .= $row["dea_marketprice"] . "^"; //PRICE $RENDER .= "0" . "^"; //PRICE_QUALIFIER if ($row["dea_psubtype"] == 4) { //PROP_SUB_ID $RENDER .= "4" . "^"; } elseif ($row["dea_psubtype"] == 5) { $RENDER .= "3" . "^"; } elseif ($row["dea_psubtype"] == 6) { $RENDER .= "1" . "^"; } elseif ($row["dea_psubtype"] == 7) { $RENDER .= "2" . "^"; } elseif ($row["dea_psubtype"] == 8) { $RENDER .= "5" . "^"; } elseif ($row["dea_psubtype"] == 9) { $RENDER .= "12" . "^"; } elseif ($row["dea_psubtype"] == 10) { $RENDER .= "26" . "^"; } elseif ($row["dea_psubtype"] == 11) { $RENDER .= "29" . "^"; } elseif ($row["dea_psubtype"] == 12) { $RENDER .= "11" . "^"; } elseif ($row["dea_psubtype"] == 13) { $RENDER .= "9" . "^"; } elseif ($row["dea_psubtype"] == 14) { $RENDER .= "19" . "^"; } elseif ($row["dea_psubtype"] == 15) { $RENDER .= "19" . "^"; } elseif ($row["dea_psubtype"] == 16) { $RENDER .= "51" . "^"; } elseif ($row["dea_psubtype"] == 17) { $RENDER .= "20" . "^"; } elseif ($row["dea_psubtype"] == 19) { $RENDER .= "28" . "^"; } elseif ($row["dea_psubtype"] == 20) { $RENDER .= "28" . "^"; } elseif ($row["dea_psubtype"] == 21) { $RENDER .= "28" . "^"; } elseif ($row["dea_psubtype"] == 22) { $RENDER .= "23" . "^"; } elseif ($row["dea_psubtype"] == 23) { $RENDER .= "28" . "^"; } elseif ($row["dea_psubtype"] == 25) { $RENDER .= "21" . "^"; } elseif ($row["dea_psubtype"] == 26) { $RENDER .= "48" . "^"; } elseif ($row["dea_psubtype"] == 27) { $RENDER .= "19" . "^"; } elseif ($row["dea_psubtype"] == 28) { $RENDER .= "19" . "^"; } elseif ($row["dea_psubtype"] == 29) { $RENDER .= "19" . "^"; } else { if ($row["dea_ptype"] == 1) { $RENDER .= "26" . "^"; } elseif ($row["dea_ptype"] == 2) { $RENDER .= "28" . "^"; } elseif ($row["dea_ptype"] == 3) { $RENDER .= "19" . "^"; } } $RENDER .= $row["dea_launchdate"] . "^"; //CREATE_DATE $RENDER .= date("Y-m-d H:i:s") . "^"; //UPDATE_DATE $RENDER .= $row["pro_addr3"] . ", " . $row["are_title"] . ", " . $postcode[0] . "^"; //DISPLAY_ADDRESS $RENDER .= "1" . "^"; //PUBLISHED_FLAG if ($row["dea_type"] == 'Lettings') { //LET_DATE_AVAILABLE $RENDER .= $row["dea_available"] . "^"; } else { $RENDER .= "^"; } $RENDER .= "^"; //LET_BOND if ($row["PriceType"] == 1) { //LET_TYPE_ID $RENDER .= "1" . "^"; } elseif ($row["PriceType"] == 2) { $RENDER .= "2" . "^"; } else { $RENDER .= "0" . "^"; } if ($row["furnished"] == 1) { //LET_FURN_ID $RENDER .= "2" . "^"; } elseif ($row["furnished"] == 2) { $RENDER .= "1" . "^"; } elseif ($row["furnished"] == 3) { $RENDER .= "0" . "^"; } else { $RENDER .= "3" . "^"; } $RENDER .= "0" . "^"; //LET_RENT_FREQUENCY if ($row["dea_type"] == 'Sales') { //TRANS_TYPE_ID $RENDER .= "1" . "^"; } else { $RENDER .= "2" . "^"; } $image_path = WS_PATH_IMAGES . '/' . $row["dea_id"] . '/'; if ($row["photos"]) { $photo_array = explode("~", $row["photos"]); } /* $max_images = sizeof($photo_array); */ $max_images = 10; for ($i = 0; $i <= $max_images; $i++) { if ($photo_array[$i]) { $photo = explode("|", $photo_array[$i]); if (file_exists($image_path . str_replace(".jpg", "_large.jpg", $photo[0]))) { $source_image = $image_path . str_replace(".jpg", "_large.jpg", $photo[0]); } elseif (file_exists($image_path . str_replace(".jpg", "_small.jpg", $photo[0]))) { $source_image = $image_path . str_replace(".jpg", "_small.jpg", $photo[0]); } $rm_image_name = $intRMBranchID . '_' . $row["dea_id"] . '_IMG_' . substr("0" . $i, -2) . '.jpg'; // if the file already exists, delet before re-writing if (file_exists($strPath . "/" . $rm_image_name)) { unlink($strPath . "/" . $rm_image_name); } copy($source_image, $strPath . "/" . $rm_image_name); $RENDER .= $rm_image_name . "^"; //MEDIA_IMAGE_00 $filesToDelete[] = $strPath . "/" . $rm_image_name; $RENDER .= $photo[1] . "^"; //MEDIA_IMAGE_TEXT_00 } else { // no image $RENDER .= "^"; //MEDIA_IMAGE_00 $RENDER .= "^"; //MEDIA_IMAGE_TEXT_00 } } // epc document if ($row["epc"]) { $epc_array = explode("~", $row["epc"]); } $max_epc = 2; for ($i = 0; $i < $max_epc; $i++) { if ($epc_array[$i]) { $epc = explode("|", $epc_array[$i]); if (file_exists($image_path . str_replace(".jpg", "_large.jpg", $epc[0]))) { $source_image = $image_path . str_replace(".jpg", "_large.jpg", $epc[0]); } elseif (file_exists($image_path . str_replace(".jpg", "_small.jpg", $epc[0]))) { $source_image = $image_path . str_replace(".jpg", "_small.jpg", $epc[0]); } $rm_image_name = $intRMBranchID . '_' . $row["dea_id"] . '_IMG_' . substr("0" . ($i + 60), -2) . '.jpg'; // if the file already exists, delet before re-writing if (file_exists($strPath . "/" . $rm_image_name)) { unlink($strPath . "/" . $rm_image_name); } copy($source_image, $strPath . "/" . $rm_image_name); $RENDER .= $rm_image_name . "^"; //MEDIA_IMAGE_00 $filesToDelete[] = $strPath . "/" . $rm_image_name; $RENDER .= $epc[1] . "^"; //MEDIA_IMAGE_TEXT_00 } else { // no image $RENDER .= "^"; //MEDIA_IMAGE_00 $RENDER .= "^"; //MEDIA_IMAGE_TEXT_00 } } // floorplans if ($row["floorplans"]) { $floorplan_array = explode("~", $row["floorplans"]); } $max_floorplans = 5; for ($i = 0; $i <= $max_floorplans; $i++) { if ($floorplan_array[$i]) { $floorplan = explode("|", $floorplan_array[$i]); if (file_exists($image_path . $floorplan[0])) { $source_image = $image_path . $floorplan[0]; } $rm_image_name = $intRMBranchID . '_' . $row["dea_id"] . '_FLP_' . substr("0" . $i, -2) . '.gif'; // if the file already exists, delete before re-writing if (file_exists($strPath . "/" . $rm_image_name)) { unlink($strPath . "/" . $rm_image_name); } copy($source_image, $strPath . "/" . $rm_image_name); $RENDER .= $rm_image_name . "^"; //MEDIA_FLOOR_PLAN_01 $filesToDelete[] = $strPath . "/" . $rm_image_name; $RENDER .= $floorplan[1] . "^"; //MEDIA_FLOOR_PLAN_TEXT_01 } else { // no image $RENDER .= "^"; //MEDIA_FLOOR_PLAN_01 $RENDER .= "^"; //MEDIA_FLOOR_PLAN_TEXT_01 } } $RENDER = $this->removeLastChar($RENDER, "^"); $RENDER = $this->removeLastChar($RENDER, "^"); // brochure $render .= "http://" . WS_HOSTNAME . "/property/pdf/" . $row['dea_id']; $RENDER .= "~\n"; //End of record + line feed } $RENDER .= "#END#"; $local_file = $strPath . "/" . date('Ymd') . ".txt"; if (!file_put_contents($local_file, $RENDER)) { die("could not write to file"); } $filesToDelete[] = $strPath . "/" . date("Ymd") . ".tar"; $this->backupsus($strPath); // delete all files in array (that is all images and the blm text file) foreach ($filesToDelete as $filename) { @unlink($filename); } $dst_dir = $CONFIG[FEED_NAME]['ftp_destination']; $ftp = new FTP($CONFIG[FEED_NAME]['ftp_server'], $CONFIG[FEED_NAME]['ftp_username'], $CONFIG[FEED_NAME]['ftp_password']); try { $ftp->upload($strPath, $dst_dir); } catch (Exception $e) { } file_put_contents(WS_PATH_LOGS . "/ftpUploadErrorLog.log", $ftp->getErrorLog(), FILE_APPEND); file_put_contents(WS_PATH_LOGS . "/ftpUploadMessageLog.log", $ftp->getMessageLog(), FILE_APPEND); // ================================================================================= // <<< functions }
<?php if (Login::getLoginSession()) { print_r($_POST); $action = req($_GET['action']); switch ($action) { case 'check': $_SESSION['action'] = 'check_connection'; //comprobar la conexion al sitio ftp $username = req('username_ftp'); $password = req('password_ftp'); $server = req('server_ftp'); $remotedir = req('remotedir'); //if($obj_ftp=new FTP($server,$username,$password,$remotedir)) //$server=null,$user=null,$passw=null if (FTP::check_connection($server, $username, $password)) { mensaje("Conexi\\u00F3n al servidor con \\u00E9xito.", "Comprobar conexión"); } else { mensaje("ERROR! Revise los datos de la conexi\\u00F3n al servidor", "", "error"); } break; } }
function ftp_ssl_connect($host, $port = 21, $timeout = 0) { // Opens an Secure SSL-FTP connection if ($timeout < 1) { $timeout = 90; } $ftp = new FTP(); if (!$ftp->ssl_connect($host, $port, $timeout)) { return false; } return $ftp; }
$out = null; if (isset($_REQUEST['path'])) { $path = htmlspecialchars($_REQUEST['path']); } else { $path = null; } if (isset($_REQUEST['content'])) { $content = $_REQUEST['content']; } else { $content = null; } if (isset($_REQUEST['act'])) { $action = htmlspecialchars($_REQUEST['act']); } else { $action = null; } // Enregistrement if ($action == 'save') { } else { if (action == 'edit') { echo htmlspecialchars(FTP::getFileContent($path)); } else { if ($action == 'down') { $pathinfo = pathinfo($path); FileFolder::sendDownloadHeaders($pathinfo['basename']); $tempFile = FTP::downloadFile($path, '../tmp/'); readfile($tempFile); exit; } } }
//MEDIA_FLOOR_PLAN_TEXT_01 } } unset($floorplan, $floorplan_array, $i); $render = remove_lastchar($render, "^"); $render = remove_lastchar($render, "^"); // brochure $render .= "http://" . WS_HOSTNAME . "/property/pdf/" . $row['dea_id']; $render .= "~\n"; //End of record + line feed // loop } // end of datafeed $render .= "#END#"; $local_file = $strPath . "/" . $strTextFile; // if the file already exists, delet before re-writing if (file_exists($local_file)) { unlink($local_file); } // write $render to file if (!file_put_contents($local_file, $render)) { echo "could not write to file"; exit; } $ftp = new FTP($CONFIG[FEED_NAME]['ftp_server'], $CONFIG[FEED_NAME]['ftp_username'], $CONFIG[FEED_NAME]['ftp_password']); try { $ftp->upload($strPath, $CONFIG[FEED_NAME]['ftp_destination']); } catch (Exception $e) { } file_put_contents(WS_PATH_LOGS . "/ftpUploadErrorLog.log", $ftp->getErrorLog(), FILE_APPEND); file_put_contents(WS_PATH_LOGS . "/ftpUploadMessageLog.log", $ftp->getMessageLog(), FILE_APPEND);
Typeframe::Redirect('Skin and/or stylesheet not specified.', Typeframe::CurrentPage()->applicationUri(), 1); } $pm->setVariable('skin', $_REQUEST['skin']); $pm->setVariable('stylesheet', $_REQUEST['stylesheet']); if (file_exists(TYPEF_DIR . "/skins/{$_REQUEST['skin']}{$_REQUEST['stylesheet']}")) { $pm->setVariable('source', file_get_contents(TYPEF_DIR . "/skins/{$_REQUEST['skin']}{$_REQUEST['stylesheet']}")); } else { if (file_exists(TYPEF_DIR . "/skins/default{$_REQUEST['stylesheet']}")) { $pm->setVariable('source', file_get_contents(TYPEF_DIR . "/skins/default{$_REQUEST['stylesheet']}")); } else { Typeframe::Redirect('Stylesheet does not exist.', Typeframe::CurrentPage()->applicationUri(), 1); return; } } if ($_POST['cmd'] == 'stylesheet-update') { $ftp = new FTP(); if (!$ftp->connect(TYPEF_FTP_HOST)) { Typeframe::Redirect('Unable to connect to FTP server.', Typeframe::CurrentPage()->applicationUri(), -1); return; } if (!$ftp->login($_SESSION['typef_ftp_user'], $_SESSION['typef_ftp_pass'])) { Typeframe::Redirect('Unable to log into FTP server.', Typeframe::CurrentPage()->applicationUri(), -1); return; } $h = tmpfile(); fwrite($h, $_REQUEST['source']); if (!fflush($h)) { die("Failed to flush"); } rewind($h); // Make sure that all required directories exist
/** * Close * * @return void */ function _close() { $this->oFtp->ftp_quit(); }
/** * Funcion principal que hace el informe de sondas detenidas * @param array $registro * @param type $lo_guardo */ private function hago_informe(array $registro, $lo_guardo = false) { $servidor = trim(utf8_decode($registro['servidor'])); $usuario = trim(utf8_decode($registro['usuario'])); $password = trim(utf8_decode($registro['password'])); $directorio = trim(utf8_decode($registro['directorio_remoto'])); $emails = explode(",", $registro['mails']); if ($obj_ftp = new FTP($servidor, $usuario, $password, $directorio)) { // hago el informe if ($informe = $this->analizo_sondas($obj_ftp->get_listado())) { if ($lo_guardo) { // y lo guardo en la base de datos $fecha_actual = date("Y-m-d H:i:s"); $query = "INSERT INTO `reports` \n (`userid`,`informe`,`fecha`) \n VALUES \n ({$registro['id']},'{$informe}','{$fecha_actual}')"; if (sql_select($query, $results)) { // envio mails envio_emails($informe, $usuario, $fecha_actual, $emails); } } } else { echo "ERROR! Hubo algún problema en la creación del informe.\n"; } } unset($results); }
public function moveToFTP($strLocalName, $strUploadFolder, $strServer, $strUsername, $strPassword, $strRemoteFolder) { $blnReturn = true; if (!empty($strLocalName)) { //*** Connect to the server. $objFtp = new FTP($strServer, NULL, NULL, TRUE); $objRet = $objFtp->login($strUsername, $strPassword); if (!$objRet) { $this->arrMessages[] = "Login failed. Check credentials."; $blnReturn = false; } //*** Passive mode. $objFtp->pasv(TRUE); //*** Transfer file. $objRet = $objFtp->nb_put($strRemoteFolder . $strLocalName, $strUploadFolder . $strLocalName, FTP_BINARY); while ($objRet == FTP_MOREDATA) { // Continue uploading... $objRet = $objFtp->nb_continue(); } if ($objRet != FTP_FINISHED) { //*** Something went wrong. $this->arrMessages[] = $this->getErrorMessage($this->intHttpError); $blnReturn = false; } //*** Remove local file. @unlink($strUploadFolder . $strLocalName); } return $blnReturn; }
function setFolder($folder) { parent::set_destination_folder($folder); }
$dedeNowurls = explode("?", $dedeNowurl); $s_scriptName = $dedeNowurls[0]; //检验用户登录状态 $cuserLogin = new userLogin(); if ($cuserLogin->getUserID() <= 0) { if (empty($adminDirHand)) { ShowMsg("<b>提示:需输入后台管理目录才能登录</b><br /><form>请输入后台管理目录名:<input type='hidden' name='gotopage' value='" . urlencode($dedeNowurl) . "' /><input type='text' name='adminDirHand' value='dede' style='width:120px;' /><input style='width:80px;' type='submit' name='sbt' value='转入登录' /></form>", "javascript:;"); exit; } $adminDirHand = HtmlReplace($adminDirHand, 1); $gurl = "../../{$adminDirHand}/login.php?gotopage=" . urlencode($dedeNowurl); echo "<script language='javascript'>location='{$gurl}';</script>"; exit; } //启用远程站点则创建FTP类 if ($cfg_remote_site == 'Y') { require_once DEDEINC . '/ftp.class.php'; if (file_exists(DEDEDATA . "/cache/inc_remote_config.php")) { require_once DEDEDATA . "/cache/inc_remote_config.php"; } if (empty($remoteuploads)) { $remoteuploads = 0; } if (empty($remoteupUrl)) { $remoteupUrl = ''; } //初始化FTP配置 $ftpconfig = array('hostname' => $rmhost, 'port' => $rmport, 'username' => $rmname, 'password' => $rmpwd); $ftp = new FTP(); $ftp->connect($ftpconfig); }
} copy($source_image, $strPath . "/" . $rm_image_name); $filesToDelete[] = $strPath . "/" . $rm_image_name; } } $render .= "\n"; //End of record + line feed $counter++; // loop } // end of datafeed $render .= "#END#"; $local_file = $strPath . "/" . $strTextFile; // if the file already exists, delet before re-writing if (file_exists($local_file)) { unlink($local_file); } // write $render to file if (!file_put_contents($local_file, $render)) { echo "could not write to file"; exit; } $src_dir = $strPath; $dst_dir = $CONFIG[FEED_NAME]['ftp_destination']; $ftp = new FTP($CONFIG[FEED_NAME]['ftp_server'], $CONFIG[FEED_NAME]['ftp_username'], $CONFIG[FEED_NAME]['ftp_password']); try { $ftp->upload($strPath, $dst_dir); } catch (Exception $e) { } file_put_contents(WS_PATH_LOGS . "/ftpUploadErrorLog.log", $ftp->getErrorLog(), FILE_APPEND); file_put_contents(WS_PATH_LOGS . "/ftpUploadMessageLog.log", $ftp->getMessageLog(), FILE_APPEND);
$template->message($LNG->getTemplate('locked_install'), false, 0, true); exit; } $language = HTTP::_GP('lang', ''); if (!empty($language) && in_array($language, $LNG->getAllowedLangs())) { setcookie('lang', $language); } $mode = HTTP::_GP('mode', ''); switch ($mode) { case 'ajax': require 'includes/libs/ftp/ftp.class.php'; require 'includes/libs/ftp/ftpexception.class.php'; $LNG->includeData(array('ADMIN')); $connectionConfig = array("host" => $_GET['host'], "username" => $_GET['user'], "password" => $_GET['pass'], "port" => 21); try { $ftp = FTP::getInstance(); $ftp->connect($connectionConfig); } catch (FTPException $error) { exit($LNG['req_ftp_error_data']); } if (!$ftp->changeDir($_GET['path'])) { exit($LNG['req_ftp_error_dir']); } $CHMOD = php_sapi_name() == 'apache2handler' ? 0777 : 0755; $ftp->chmod('cache', $CHMOD); $ftp->chmod('includes', $CHMOD); $ftp->chmod('install', $CHMOD); break; case 'install': $step = HTTP::_GP('step', 0); switch ($step) {
* */ Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']); //Tests Route::get('admin/mibor_buyers', 'RetsController@buyerQuery'); Route::get('admin/mibor_sellers', 'RetsController@sellerQuery'); Route::get('admin/mibor_sellers/{office}/{start}/{end}', 'RetsController@sellerQuery'); Route::get('admin/mibor_buyers/{office}/{start}/{end}', 'RetsController@buyerQuery'); Route::get('admin/mibor_test/{agent_id}/{start_range}/{end_range}', 'RetsController@test'); Route::get('test', function () { // $user = \App\C21\Users\User::where('id',1)->with('groups')->first(); //dd($user->groups[0]->name); return view('emails.email_1'); }); Route::get('admin/ftp', function () { $listing = FTP::connection()->downloadFile('Agents.xml', storage_path() . '/c21/Agents.xml'); if ($listing === true) { return redirect('admin/agents_go'); } die('The file failed for some reason'); }); Route::get('webvideos/{video}', function ($video) { $random = rand(1, 1); $video_path = base_path('public/videos') . '/folder_' . $random . '/' . $video; $stream = new \App\Videos\VideoStream($video_path); $stream->start(); }); Route::get('video', function () { return view('tests/video'); }); Route::get('admin/agents_go', function () {
$newkey = preg_replace('/:/', '', $key); $short_to_longs[$newkey] = $val; } $options = getopt(implode('', array_keys($parameters)), $parameters); foreach ($short_to_longs as $short => $long) { if (array_key_exists($short, $options)) { $options[$long] = $options[$short]; unset($options[$short]); } } if (array_key_exists('config-file', $options) && is_readable($options['config-file'])) { $CONFIG_FILE = $options['config-file']; } include '/etc/lms/init_lms.php'; include_once LIB_DIR . '/FTP.class.php'; $FTP = new FTP(get_conf('autobackup.ftphost'), get_conf('autobackup.ftpuser'), get_conf('autobackup.ftppass'), 21, 120); if (array_key_exists('quiet', $options)) { $quiet = true; } else { $quiet = false; } if (array_key_exists('help', $options)) { print <<<EOF lms-autobackup.php version 1.0.0 (C) 2012-2013 iNET LMS -C, --config-file=/etc/lms/lms.ini alternatywny plik konfiguracyjny (default: /etc/lms/lms.ini); -h, --help wyswietlenie pomocy i zakonczenie; -q, --quiet nie wyswietla dodatkowych informacji;
function parsePages($intElmntId, $strCommand) { global $objLang, $_CLEAN_POST, $objLiveUser, $_CONF, $_PATHS, $DBAConn, $objMultiUpload; $objTpl = new HTML_Template_IT($_PATHS['templates']); $blnUiError = Request::get('err', 0); switch ($strCommand) { case CMD_LIST: $objTpl->loadTemplatefile("multiview.tpl.htm"); $objTpl->setVariable("MAINTITLE", $objLang->get("pcmsElements", "menu")); $objElement = Element::selectByPK($intElmntId); if (empty($intElmntId)) { $strElmntName = "Website"; } else { if (is_object($objElement)) { $strElmntName = $objElement->getName(); } else { $strElmntName = ""; } } if (is_object($objElement) || empty($intElmntId)) { if (empty($intElmntId)) { $objElements = Elements::getFromParent(0, false); } else { $objElements = $objElement->getElements(false); } if (is_object($objElements)) { //*** Initiate child element loop. $listCount = 0; $intPosition = request("pos"); $intPosition = !empty($intPosition) && is_numeric($intPosition) ? $intPosition : 0; $intPosition = floor($intPosition / $_SESSION["listCount"]) * $_SESSION["listCount"]; $objElements->seek($intPosition); //*** Loop through the elements. foreach ($objElements as $objSubElement) { //if (Permissions::hasElementPermission(SPINCMS_ELEMENTS_READ, $objSubElement)) { $objTemplate = Template::selectByPK($objSubElement->getTemplateId(), array('name')); $strMeta = $objLang->get("editedBy", "label") . " " . $objSubElement->getUsername() . ", " . Date::fromMysql($objLang->get("datefmt"), $objSubElement->getModified()); $objTpl->setCurrentBlock("multiview-item"); if ($objSubElement->getTypeId() != ELM_TYPE_LOCKED) { $objTpl->setVariable("BUTTON_DUPLICATE", $objLang->get("duplicate", "button")); $objTpl->setVariable("BUTTON_DUPLICATE_HREF", "javascript:PElement.duplicate({$objSubElement->getId()});"); $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("delete", "button")); $objTpl->setVariable("BUTTON_REMOVE_HREF", "javascript:PElement.remove({$objSubElement->getId()});"); } $objTpl->setVariable("MULTIITEM_VALUE", $objSubElement->getId()); //if (Permissions::hasElementPermission(SPINCMS_ELEMENTS_WRITE, $objSubElement)) { $objTpl->setVariable("MULTIITEM_HREF", "href=\"?cid=" . NAV_PCMS_ELEMENTS . "&eid={$objSubElement->getId()}&cmd=" . CMD_EDIT . "\""); //} else { // $objTpl->setVariable("MULTIITEM_HREF", ""); //} if ($objSubElement->getActive() < 1) { $objTpl->setVariable("MULTIITEM_ACTIVE", " class=\"inactive\""); } $strValue = htmlspecialchars($objSubElement->getName()); $strShortValue = getShortValue($strValue, 50); $intSize = strlen($strValue); $objTpl->setVariable("MULTIITEM_NAME", $intSize > 50 ? $strShortValue : $strValue); $objTpl->setVariable("MULTIITEM_TITLE", $intSize > 50 ? $strValue : ""); $strTypeClass = ""; if ($objSubElement->getTypeId() == ELM_TYPE_FOLDER) { $strTypeClass = "folder"; } else { $objChildElements = $objSubElement->getElements(); if (is_object($objChildElements) && $objChildElements->count() > 0) { switch ($objSubElement->getTypeId()) { case ELM_TYPE_DYNAMIC: $strTypeClass = "widget-dynamic"; break; case ELM_TYPE_LOCKED: $strTypeClass = "widget-locked"; break; default: $strTypeClass = "widget"; } } else { switch ($objSubElement->getTypeId()) { case ELM_TYPE_DYNAMIC: $strTypeClass = "element-dynamic"; break; case ELM_TYPE_LOCKED: $strTypeClass = "element-locked"; break; default: $strTypeClass = "element"; } } } $objTpl->setVariable("MULTIITEM_TYPE_CLASS", $strTypeClass); if (is_object($objTemplate)) { $objTpl->setVariable("MULTIITEM_TYPE", ", " . $objTemplate->getName()); } $objTpl->setVariable("MULTIITEM_META", $strMeta); $objTpl->parseCurrentBlock(); $listCount++; if ($listCount >= $_SESSION["listCount"]) { break; } //} } //*** Render page navigation. $pageCount = ceil($objElements->count() / $_SESSION["listCount"]); if ($pageCount > 0) { $currentPage = ceil(($intPosition + 1) / $_SESSION["listCount"]); $previousPos = $intPosition - $_SESSION["listCount"] > 0 ? $intPosition - $_SESSION["listCount"] : 0; $nextPos = $intPosition + $_SESSION["listCount"] < $objElements->count() ? $intPosition + $_SESSION["listCount"] : $intPosition; $objTpl->setVariable("PAGENAV_PAGE", sprintf($objLang->get("pageNavigation", "label"), $currentPage, $pageCount)); $objTpl->setVariable("PAGENAV_PREVIOUS", $objLang->get("previous", "button")); $objTpl->setVariable("PAGENAV_PREVIOUS_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}&pos={$previousPos}"); $objTpl->setVariable("PAGENAV_NEXT", $objLang->get("next", "button")); $objTpl->setVariable("PAGENAV_NEXT_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}&pos={$nextPos}"); //*** Top page navigation. for ($intCount = 0; $intCount < $pageCount; $intCount++) { $objTpl->setCurrentBlock("multiview-pagenavitem-top"); $position = $intCount * $_SESSION["listCount"]; if ($intCount != $intPosition / $_SESSION["listCount"]) { $objTpl->setVariable("PAGENAV_HREF", "href=\"?cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}&pos={$position}\""); } $objTpl->setVariable("PAGENAV_VALUE", $intCount + 1); $objTpl->parseCurrentBlock(); } //*** Bottom page navigation. for ($intCount = 0; $intCount < $pageCount; $intCount++) { $objTpl->setCurrentBlock("multiview-pagenavitem-bottom"); $position = $intCount * $_SESSION["listCount"]; if ($intCount != $intPosition / $_SESSION["listCount"]) { $objTpl->setVariable("PAGENAV_HREF", "href=\"?cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}&pos={$position}\""); } $objTpl->setVariable("PAGENAV_VALUE", $intCount + 1); $objTpl->parseCurrentBlock(); } } } } //*** Render list action pulldown. if (!is_object($objElement) || $objElement->getTypeId() != ELM_TYPE_LOCKED) { $arrActions[$objLang->get("choose", "button")] = 0; $arrActions[$objLang->get("delete", "button") . " "] = "delete"; $arrActions[$objLang->get("duplicate", "button") . " "] = "duplicate"; $arrActions[$objLang->get("activate", "button") . " "] = "activate"; $arrActions[$objLang->get("deactivate", "button") . " "] = "deactivate"; if (is_object($objElement)) { $arrActions[$objLang->get("export", "button") . " "] = "export"; } foreach ($arrActions as $key => $value) { $objTpl->setCurrentBlock("multiview-listactionitem"); $objTpl->setVariable("LIST_ACTION_TEXT", $key); $objTpl->setVariable("LIST_ACTION_VALUE", $value); $objTpl->parseCurrentBlock(); } } //*** Render the rest of the page. $objTpl->setCurrentBlock("multiview"); $objTpl->setVariable("ACTIONS_OPEN", $objLang->get("pcmsOpenActionsMenu", "menu")); $objTpl->setVariable("ACTIONS_CLOSE", $objLang->get("pcmsCloseActionsMenu", "menu")); $objTpl->setVariable("LIST_LENGTH_HREF_10", "href=\"?list=10&cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}\""); $objTpl->setVariable("LIST_LENGTH_HREF_25", "href=\"?list=25&cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}\""); $objTpl->setVariable("LIST_LENGTH_HREF_100", "href=\"?list=100&cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}\""); switch ($_SESSION["listCount"]) { case 10: $objTpl->setVariable("LIST_LENGTH_HREF_10", ""); break; case 25: $objTpl->setVariable("LIST_LENGTH_HREF_25", ""); break; case 100: $objTpl->setVariable("LIST_LENGTH_HREF_100", ""); break; } $objTpl->setVariable("LIST_LENGTH_HREF", "&cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}"); if (!is_object($objElement) || $objElement->getTypeId() != ELM_TYPE_LOCKED) { $objTpl->setVariable("LIST_WITH_SELECTED", $objLang->get("withSelected", "label")); $objTpl->setVariable("BUTTON_LIST_SELECT", $objLang->get("selectAll", "button")); $objTpl->setVariable("BUTTON_LIST_SELECT_HREF", "javascript:PElement.multiSelect()"); $objTpl->setVariable("LIST_ACTION_ONCHANGE", "PElement.multiDo(this, this[this.selectedIndex].value)"); } $objTpl->setVariable("LIST_ITEMS_PER_PAGE", $objLang->get("itemsPerPage", "label")); if (!isset($objElement) || $objElement->getTypeId() != ELM_TYPE_DYNAMIC && $objElement->getTypeId() != ELM_TYPE_LOCKED) { $objTpl->setVariable("BUTTON_NEWSUBJECT", $objLang->get("newElement", "button")); $objDefaultLang = ContentLanguage::getDefault(); if (!is_object($objDefaultLang)) { $objTpl->setVariable("BUTTON_NEWSUBJECT_HREF", "javascript:alert('" . $objLang->get("elementBeforeLanguage", "alert") . "')"); } else { $objTpl->setVariable("BUTTON_NEWSUBJECT_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}&cmd=" . CMD_ADD); } $objTpl->setVariable("BUTTON_NEWFOLDER", $objLang->get("newFolder", "button")); $objTpl->setVariable("BUTTON_NEWFOLDER_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}&cmd=" . CMD_ADD_FOLDER); if ($objLiveUser->checkRight($_CONF['app']['navRights'][NAV_PCMS_TEMPLATES] == true)) { $objTpl->setVariable("BUTTON_EXPORT_ELEMENT", $objLang->get("export", "button")); $objTpl->setVariable("BUTTON_EXPORT_ELEMENT_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}&cmd=" . CMD_EXPORT_ELEMENT); $objTpl->setVariable("BUTTON_IMPORT_ELEMENT", $objLang->get("import", "button")); $objTpl->setVariable("BUTTON_IMPORT_ELEMENT_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}&cmd=" . CMD_IMPORT_ELEMENT); } } if (!isset($objElement) || $objElement->getTypeId() != ELM_TYPE_LOCKED) { $objTpl->setVariable("BUTTON_NEWDYNAMIC", $objLang->get("newDynamic", "button")); $objTpl->setVariable("BUTTON_NEWDYNAMIC_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}&cmd=" . CMD_ADD_DYNAMIC); if ($intElmntId > 0) { $objElement = Element::selectByPK($intElmntId); $objTpl->setVariable("BUTTON_EDIT", $objLang->get("edit", "button")); $objTpl->setVariable("BUTTON_EDIT_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}&cmd=" . CMD_EDIT); } } $objTpl->setVariable("LABEL_SUBJECT", $objLang->get("elementsIn", "label") . " "); $objTpl->setVariable("SUBJECT_NAME", $strElmntName); $objTpl->setVariable("EID", $intElmntId); $objTpl->parseCurrentBlock(); break; case CMD_REMOVE: if (strpos($intElmntId, ',') !== false) { //*** Multiple elements submitted. $arrElements = explode(',', $intElmntId); $objElements = Element::selectByPK($arrElements); $intParent = $objElements->current()->getParentId(); foreach ($objElements as $objElement) { $objElement->delete(); } } else { //*** Single element submitted. $objElement = Element::selectByPK($intElmntId); $intParent = $objElement->getParentId(); $objElement->delete(); } //*** Redirect the page. $strReturnTo = request('returnTo'); if (empty($strReturnTo)) { header("Location: " . Request::getUri() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intParent); exit; } else { header("Location: " . Request::getURI() . $strReturnTo); exit; } break; case CMD_DUPLICATE: if (strpos($intElmntId, ',') !== false) { //*** Multiple elements submitted. $arrElements = explode(',', $intElmntId); $objElements = Element::selectByPK($arrElements); $intParent = $objElements->current()->getParentId(); foreach ($objElements as $objElement) { $objElement->setUsername($objLiveUser->getProperty("name")); $objDuplicate = $objElement->duplicate($objLang->get("copyOf", "label")); //*** Update the search index. $objSearch = new Search(); $objSearch->updateIndex($objDuplicate->getId()); } } else { //*** Single element submitted. $objElement = Element::selectByPK($intElmntId); $intParent = $objElement->getParentId(); $objElement->setUsername($objLiveUser->getProperty("name")); $objDuplicate = $objElement->duplicate($objLang->get("copyOf", "label")); //*** Update the search index. $objSearch = new Search(); $objSearch->updateIndex($objDuplicate->getId()); } //*** Redirect the page. $strReturnTo = request('returnTo'); if (empty($strReturnTo)) { header("Location: " . Request::getURI() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intParent); exit; } else { header("Location: " . Request::getURI() . $strReturnTo); exit; } break; case CMD_ACTIVATE: case CMD_DEACTIVATE: if (strpos($intElmntId, ',') !== false) { //*** Multiple elements submitted. $arrElements = explode(',', $intElmntId); $objElements = Element::selectByPK($arrElements); $intParent = $objElements->current()->getParentId(); foreach ($objElements as $objElement) { if ($strCommand == CMD_ACTIVATE) { $objElement->setActive(1); } else { $objElement->setActive(0); } $objElement->save(); } } else { //*** Single element submitted. $objElement = Element::selectByPK($intElmntId); $intParent = $objElement->getParentId(); if ($strCommand == CMD_ACTIVATE) { $objElement->setActive(1); } else { $objElement->setActive(0); } $objElement->save(); } //*** Redirect the page. $strReturnTo = request('returnTo'); if (empty($strReturnTo)) { header("Location: " . Request::getURI() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intParent); exit; } else { header("Location: " . Request::getURI() . $strReturnTo); exit; } break; case CMD_ADD: case CMD_EDIT: case CMD_ADD_FOLDER: case CMD_ADD_DYNAMIC: $objTpl->loadTemplatefile("elementfields.tpl.htm"); $blnError = false; $blnIsFolder = false; $blnIsDynamic = false; //*** Check the element type (element or folder) if ($strCommand == CMD_EDIT) { $objElement = Element::selectByPK($intElmntId); if (is_object($objElement) && $objElement->getTypeId() == ELM_TYPE_FOLDER) { $blnIsFolder = true; } else { if (is_object($objElement) && $objElement->getTypeId() == ELM_TYPE_DYNAMIC) { $blnIsDynamic = true; } } } else { if ($strCommand == CMD_ADD_FOLDER) { $blnIsFolder = true; } else { if ($strCommand == CMD_ADD_DYNAMIC) { $blnIsDynamic = true; } } } //*** Check if the rootfolder has been submitted. if ($strCommand == CMD_EDIT && $intElmntId == 0) { //*** Redirect to list mode. header("Location: " . Request::getURI() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intElmntId); exit; } //*** Check if an invalid element has been submitted. if ($strCommand == CMD_EDIT && !is_object($objElement)) { //*** Redirect to list mode. header("Location: " . Request::getURI() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=0"); exit; } //*** Set section title. if ($blnIsFolder) { if ($strCommand == CMD_EDIT) { $objTpl->setVariable("MAINTITLE", $objLang->get("folderDetailsFor", "label")); $objTpl->setVariable("MAINSUB", $objElement->getName()); } else { $objTpl->setVariable("MAINTITLE", $objLang->get("folderDetails", "label")); } } else { if ($blnIsDynamic) { if ($strCommand == CMD_EDIT) { $objTpl->setVariable("MAINTITLE", $objLang->get("dynamicDetailsFor", "label")); $objTpl->setVariable("MAINSUB", $objElement->getName()); } else { $objTpl->setVariable("MAINTITLE", $objLang->get("dynamicDetails", "label")); } } else { if ($strCommand == CMD_EDIT) { $objTpl->setVariable("MAINTITLE", $objLang->get("pageDetailsFor", "label")); $objTpl->setVariable("MAINSUB", $objElement->getName()); } else { $objTpl->setVariable("MAINTITLE", $objLang->get("pageDetails", "label")); } } } //*** Post the element form if submitted. if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "addElement") { //*** The element form has been posted. //*** Check sanitized input. if (is_null($_CLEAN_POST["frm_active"])) { $objTpl->setVariable("ERROR_ACTIVE_ON", " error"); $objTpl->setVariable("ERROR_ACTIVE", $objLang->get("active", "formerror")); $blnError = true; } if ($strCommand == CMD_ADD_FOLDER || $blnIsFolder) { if (is_null($_CLEAN_POST["frm_ispage"])) { $objTpl->setVariable("ERROR_ISPAGE_ON", " error"); $objTpl->setVariable("ERROR_ISPAGE", $objLang->get("isPage", "formerror")); $blnError = true; } } if ($strCommand == CMD_ADD_DYNAMIC || $blnIsDynamic) { if (is_null($_CLEAN_POST["frm_feed"])) { $objTpl->setVariable("ERROR_FEED_ON", " error"); $objTpl->setVariable("ERROR_FEED", $objLang->get("feed", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_feedpath"])) { $objTpl->setVariable("ERROR_FEEDPATH_ON", " error"); $objTpl->setVariable("ERROR_FEEDPATH", $objLang->get("feedPath", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_maxitems"])) { $objTpl->setVariable("ERROR_MAXITEMS_ON", " error"); $objTpl->setVariable("ERROR_MAXITEMS", $objLang->get("maxItems", "formerror")); $blnError = true; } } if (is_null($_CLEAN_POST["frm_name"])) { $objTpl->setVariable("ERROR_NAME_ON", " error"); $objTpl->setVariable("ERROR_NAME", $objLang->get("templateName", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_apiname"])) { $objTpl->setVariable("ERROR_APINAME_ON", " error"); $objTpl->setVariable("ERROR_APINAME", $objLang->get("commonTypeWord", "formerror")); $blnError = true; } /* if (is_null($_CLEAN_POST["frm_alias"])) { $objTpl->setVariable("ERROR_ALIAS_ON", " error"); $objTpl->setVariable("ERROR_ALIAS", $objLang->get("commonTypeWord", "formerror")); $blnError = true; } */ if (is_null($_CLEAN_POST["frm_template"]) && !$blnIsFolder) { $objTpl->setVariable("ERROR_TEMPLATE_ON", " error"); $objTpl->setVariable("ERROR_TEMPLATE", $objLang->get("commonTypeText", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_description"])) { $objTpl->setVariable("ERROR_NOTES_ON", " error"); $objTpl->setVariable("ERROR_NOTES", $objLang->get("commonTypeText", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["dispatch"])) { $blnError = true; } //*** Check element specific fields. //*** TODO!! if ($blnError === true) { //*** Display global error. if ($blnIsFolder) { $objTpl->setVariable("FORM_ISPAGE_VALUE", isset($_POST["frm_ispage"]) && $_POST["frm_ispage"] == "on" ? "checked=\"checked\"" : ""); } $objTpl->setVariable("FORM_ACTIVE_VALUE", isset($_POST["frm_active"]) && $_POST["frm_active"] == "on" ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_NAME_VALUE", $_POST["frm_name"]); $objTpl->setVariable("FORM_APINAME_VALUE", $_POST["frm_apiname"]); //$objTpl->setVariable("FORM_ALIAS_VALUE", $_POST["frm_alias"]); if ($blnIsDynamic) { $objTpl->setVariable("FORM_MAXITEMS_VALUE", $_POST["frm_maxitems"]); } $objTpl->setVariable("FORM_NOTES_VALUE", $_POST["frm_description"]); $objTpl->setVariable("ERROR_MAIN", $objLang->get("main", "formerror")); //*** Display element specific errors. //*** TODO!! } else { //*** Input is valid. Save the element. if ($strCommand == CMD_EDIT) { $objElement = Element::selectByPK($intElmntId); $objParent = Element::selectByPK($objElement->getParentId()); } else { $objParent = Element::selectByPK($_POST["eid"]); $objPermissions = new ElementPermission(); if (is_object($objParent)) { $objPermissions->setUserId($objParent->getPermissions()->getUserId()); $objPermissions->setGroupId($objParent->getPermissions()->getGroupId()); } $objElement = new Element(); $objElement->setParentId($_POST["eid"]); $objElement->setAccountId($_CONF['app']['account']->getId()); $objElement->setPermissions($objPermissions); } $objElement->setActive(empty($_CLEAN_POST["frm_active"]) ? 0 : 1); $objElement->setIsPage(empty($_CLEAN_POST["frm_ispage"]) ? 0 : 1); $objElement->setName($_CLEAN_POST["frm_name"]); $objElement->setApiName($_CLEAN_POST["frm_apiname"]); $objElement->setDescription($_CLEAN_POST["frm_description"]); $objElement->setUsername($objLiveUser->getProperty("name")); //*** Get remote settings. $strServer = Setting::getValueByName('ftp_server'); $strUsername = Setting::getValueByName('ftp_username'); $strPassword = Setting::getValueByName('ftp_password'); $strRemoteFolder = Setting::getValueByName('ftp_remote_folder'); if ($blnIsFolder) { $objElement->setTypeId(ELM_TYPE_FOLDER); } else { if ($blnIsDynamic) { $objElement->setTypeId(ELM_TYPE_DYNAMIC); $objElement->setTemplateId($_CLEAN_POST["frm_template"]); } else { $objElement->setTypeId(ELM_TYPE_ELEMENT); $objElement->setTemplateId($_CLEAN_POST["frm_template"]); } } $objElement->save(); if ($blnIsDynamic) { $intFeedId = $_CLEAN_POST["frm_feed"]; if (empty($intFeedId)) { $intFeedId = $objParent->getFeed()->getFeedId(); } $objElementFeed = new ElementFeed(); $objElementFeed->setFeedId($intFeedId); $objElementFeed->setFeedPath($_CLEAN_POST["frm_feedpath"]); $objElementFeed->setMaxItems($_CLEAN_POST["frm_maxitems"]); if ($_CLEAN_POST["frm_dynamic_alias_check"]) { $objElementFeed->setAliasField($_CLEAN_POST["frm_dynamic_alias"]); } else { $objElementFeed->setAliasField(""); } $objElement->setFeed($objElementFeed); } //*** Handle the publish values. $objElement->clearSchedule(); $objSchedule = new ElementSchedule(); if (!empty($_CLEAN_POST["publish_start"])) { $strDate = $_CLEAN_POST["publish_start_date"]; if (empty($strDate)) { $strDate = strftime($_CONF['app']['universalDate']); } $strDate = Date::convertDate($strDate, $_CONF['app']['universalDate'], "%d %B %Y"); $strHour = empty($_CLEAN_POST["publish_start_hour"]) ? "00" : $_CLEAN_POST["publish_start_hour"]; $strMinute = empty($_CLEAN_POST["publish_start_minute"]) ? "00" : $_CLEAN_POST["publish_start_minute"]; $strDate = $strDate . " " . $strHour . ":" . $strMinute . ":00"; $objSchedule->setStartActive(1); $objSchedule->setStartDate(Date::toMysql($strDate)); } else { //*** If not set we set the date to 0. This is nessecary for the client side library, $objSchedule->setStartActive(0); $objSchedule->setStartDate(APP_DEFAULT_STARTDATE); } if (!empty($_CLEAN_POST["publish_end"])) { $strDate = $_CLEAN_POST["publish_end_date"]; if (empty($strDate)) { $strDate = strftime($_CONF['app']['universalDate']); } $strDate = Date::convertDate($strDate, $_CONF['app']['universalDate'], "%d %B %Y"); $strHour = empty($_CLEAN_POST["publish_end_hour"]) ? "00" : $_CLEAN_POST["publish_end_hour"]; $strMinute = empty($_CLEAN_POST["publish_end_minute"]) ? "00" : $_CLEAN_POST["publish_end_minute"]; $strDate = $strDate . " " . $strHour . ":" . $strMinute . ":00"; $objSchedule->setEndActive(1); $objSchedule->setEndDate(Date::toMysql($strDate)); } else { //*** If not set we set the date in the far future. This is nessecary for the client side library, $objSchedule->setEndActive(0); $objSchedule->setEndDate(APP_DEFAULT_ENDDATE); } $objElement->setSchedule($objSchedule); //*** Handle the meta values. if ($objElement->isPage()) { $objElement->clearMeta(); $objElement->clearAliases(); $arrFields = array("title", "keywords", "description"); $objContentLangs = ContentLanguage::select(); foreach ($objContentLangs as $objContentLanguage) { //*** Insert the value by language. foreach ($arrFields as $value) { $objMeta = new ElementMeta(); $arrCascades = explode(",", request("frm_meta_{$value}_cascades")); $blnCascade = in_array($objContentLanguage->getId(), $arrCascades) ? 1 : 0; $objMeta->setName($value); $objMeta->setValue(request("frm_meta_{$value}_{$objContentLanguage->getId()}")); $objMeta->setLanguageId($objContentLanguage->getId()); $objMeta->setCascade($blnCascade); $objElement->setMeta($objMeta); } $objAlias = new Alias(); $arrCascades = explode(",", request("frm_meta_alias_cascades")); $blnCascade = in_array($objContentLanguage->getId(), $arrCascades) ? 1 : 0; $objAlias->setAlias(request("frm_meta_alias_{$objContentLanguage->getId()}")); $objAlias->setLanguageId($objContentLanguage->getId()); $objAlias->setCascade($blnCascade); $objElement->setAlias($objAlias); } } //*** Handle element values. if (!$blnIsFolder) { //*** Cache and clear values. $objCachedFields = $objElement->getFields(true); $objElement->clearFields(); $objElement->clearLanguages(); //*** Insert the active flag by language. $arrActives = explode(",", request("language_actives")); $objContentLangs = ContentLanguage::select(); foreach ($objContentLangs as $objContentLanguage) { $blnActive = in_array($objContentLanguage->getId(), $arrActives) ? true : false; $objElement->setLanguageActive($objContentLanguage->getId(), $blnActive); if ($strCommand == CMD_ADD && !isset($_POST['language_actives'])) { $objElement->setLanguageActive($objContentLanguage->getId(), true); } } //*** Cache to handsome array. $arrFieldCache = array(); foreach ($objCachedFields as $objCacheField) { foreach ($objContentLangs as $objContentLanguage) { if ($objCacheField->getTypeId() == FIELD_TYPE_FILE || $objCacheField->getTypeId() == FIELD_TYPE_IMAGE) { $arrFieldCache[$objCacheField->getTemplateFieldId()][$objContentLanguage->getId()] = $objCacheField->value[$objContentLanguage->getId()]->getValue(); } } } foreach ($_REQUEST as $key => $value) { //*** Template Fields. if (substr($key, 0, 4) == "efv_") { //*** Get the template Id from the request $intTemplateFieldId = substr($key, 4); //*** Is the Id really an Id? if (is_numeric($intTemplateFieldId)) { $objTemplateField = TemplateField::selectByPK($intTemplateFieldId); $objField = new ElementField(); $objField->setElementId($objElement->getId()); $objField->setTemplateFieldId($intTemplateFieldId); $objField->save(); //*** Get the cascade value for the currentfield. $arrCascades = explode(",", request("efv_{$intTemplateFieldId}_cascades")); //*** Loop through the languages to insert the value by language. $objContentLangs = ContentLanguage::select(); foreach ($objContentLangs as $objContentLanguage) { //*** Insert the value by language. in_array($objContentLanguage->getId(), $arrCascades) ? $blnCascade = true : ($blnCascade = false); $strValue = request("efv_{$intTemplateFieldId}_{$objContentLanguage->getId()}"); //*** Check for certain type requirements. switch ($objTemplateField->getTypeId()) { case FIELD_TYPE_FILE: case FIELD_TYPE_IMAGE: $cacheFileValue = ""; $arrCurrent = is_array($strValue) ? $strValue : array(); foreach ($arrCurrent as $value) { if (!empty($value)) { $arrFile = explode(":", $value); if (count($arrFile) > 1 && !empty($arrFile[1])) { $cacheFileValue .= $value . "\n"; //*** Remove file from cache. if (isset($arrFieldCache[$intTemplateFieldId]) && isset($arrFieldCache[$intTemplateFieldId][$objContentLanguage->getId()])) { $arrFieldCache[$intTemplateFieldId][$objContentLanguage->getId()] = str_replace($value, "", $arrFieldCache[$intTemplateFieldId][$objContentLanguage->getId()]); } } } } //*** Multifile SWFUpload foreach ($arrCurrent as $value) { if (!empty($value)) { $arrFile = explode(":", $value); if (count($arrFile) > 1 && empty($arrFile[1])) { //*** Any image manipulation? $strLocalValue = ImageField::filename2LocalName($arrFile[0]); $objImageField = new ImageField($intTemplateFieldId); $arrSettings = $objImageField->getSettings(); if (count($arrSettings) > 1) { foreach ($arrSettings as $key => $arrSetting) { $strFileName = FileIO::add2Base($strLocalValue, $arrSetting['key']); if (copy($_PATHS['upload'] . $arrFile[0], $_PATHS['upload'] . $strFileName)) { if ($objTemplateField->getTypeId() == FIELD_TYPE_IMAGE && (!empty($arrSetting['width']) || !empty($arrSetting['height']))) { //*** Check if the image has the right size. $blnResize = true; $arrSize = getimagesize($_PATHS['upload'] . $strFileName); if ($arrSize !== false) { if ($arrSize[0] == $arrSetting['width'] && $arrSize[1] == $arrSetting['height']) { //*** Skip image resize. $blnResize = false; } } //*** Resize the image. if ($blnResize) { $intQuality = empty($arrSetting['quality']) ? 75 : $arrSetting['quality']; ImageResizer::resize($_PATHS['upload'] . $strFileName, $arrSetting['width'], $arrSetting['height'], $arrSetting['scale'], $intQuality, true, NULL, false, $arrSetting['grayscale']); } } //*** Move file to remote server. $objUpload = new SingleUpload(); if (!$objUpload->moveToFTP($strFileName, $_PATHS['upload'], $strServer, $strUsername, $strPassword, $strRemoteFolder)) { Log::handleError("File could not be moved to remote server. " . $objUpload->errorMessage()); } } } //*** Move original file. if (rename($_PATHS['upload'] . $arrFile[0], $_PATHS['upload'] . $strLocalValue)) { $objUpload = new SingleUpload(); if (!$objUpload->moveToFTP($strLocalValue, $_PATHS['upload'], $strServer, $strUsername, $strPassword, $strRemoteFolder)) { Log::handleError("File could not be moved to remote server. " . $objUpload->errorMessage()); } } //*** Unlink original file. @unlink($_PATHS['upload'] . $arrFile[0]); } else { if ($objTemplateField->getTypeId() == FIELD_TYPE_IMAGE && (!empty($arrSettings[0]['width']) || !empty($arrSettings[0]['height']))) { $strFileName = FileIO::add2Base($strLocalValue, $arrSettings[0]['key']); //*** Resize the image. if (rename($_PATHS['upload'] . $arrFile[0], $_PATHS['upload'] . $strFileName)) { //*** Check if the image has the right size. $blnResize = true; $arrSize = getimagesize($_PATHS['upload'] . $strFileName); if ($arrSize !== false) { if ($arrSize[0] == $arrSettings[0]['width'] && $arrSize[1] == $arrSettings[0]['height']) { //*** Skip image resize. $blnResize = false; } } if ($blnResize) { $intQuality = empty($arrSettings[0]['quality']) ? 75 : $arrSettings[0]['quality']; ImageResizer::resize($_PATHS['upload'] . $strFileName, $arrSettings[0]['width'], $arrSettings[0]['height'], $arrSettings[0]['scale'], $intQuality, true, NULL, false, $arrSettings[0]['grayscale']); } //*** Move file to remote server. $objUpload = new SingleUpload(); if (!$objUpload->moveToFTP($strFileName, $_PATHS['upload'], $strServer, $strUsername, $strPassword, $strRemoteFolder)) { Log::handleError("File could not be moved to remote server."); } } } //*** Move original file. if (file_exists($_PATHS['upload'] . $arrFile[0]) && rename($_PATHS['upload'] . $arrFile[0], $_PATHS['upload'] . $strLocalValue)) { //*** Move file to remote server. $objUpload = new SingleUpload(); if (!$objUpload->moveToFTP($strLocalValue, $_PATHS['upload'], $strServer, $strUsername, $strPassword, $strRemoteFolder)) { Log::handleError("File could not be moved to remote server."); } } //*** Unlink original file. @unlink($_PATHS['upload'] . $arrFile[0]); } //*** Set file value. $cacheFileValue .= $arrFile[0] . ":" . $strLocalValue . "\n"; } } } //*** Check newly uploaded files. $strFiles = "efv_{$intTemplateFieldId}_{$objContentLanguage->getId()}_new"; $fileValue = $cacheFileValue; if (isset($_FILES[$strFiles])) { if ($objTemplateField->getTypeId() == FIELD_TYPE_FILE) { $objValue = $objTemplateField->getValueByName("tfv_file_extension"); $strExtensions = is_object($objValue) ? $objValue->getValue() : ""; if (!empty($strExtensions)) { $strExtensions = str_replace("%s", Setting::getValueByName('file_upload_extensions'), $strExtensions); $objMultiUpload->setExtensions(explode(" ", strtolower($strExtensions))); } else { $objMultiUpload->setExtensions(explode(" ", strtolower(Setting::getValueByName('file_upload_extensions')))); } } else { $objMultiUpload->setExtensions(explode(" ", strtolower(Setting::getValueByName('image_upload_extensions')))); } $objMultiUpload->setTempNames($_FILES[$strFiles]['tmp_name']); $objMultiUpload->setOriginalNames($_FILES[$strFiles]['name']); $objMultiUpload->setErrors($_FILES[$strFiles]['error']); $objMultiUpload->uploadFiles(); if ($objMultiUpload->getTotalFiles() == $objMultiUpload->getSuccessFiles()) { //*** Everything is cool. $localValues = $objMultiUpload->getLocalNames(); //*** Any image manipulation? $blnResize = false; $objImageField = new ImageField($intTemplateFieldId); $arrSettings = $objImageField->getSettings(); if ($objTemplateField->getTypeId() == FIELD_TYPE_IMAGE && (!empty($arrSettings[0]['width']) || !empty($arrSettings[0]['height']))) { $blnResize = true; } foreach ($objMultiUpload->getOriginalNames() as $subkey => $subvalue) { if (!empty($subvalue)) { $fileValue .= $subvalue . ":" . $localValues[$subkey] . "\n"; //*** Check if the image has the right size. if ($blnResize) { $arrSize = getimagesize($_PATHS['upload'] . $localValues[$subkey]); if ($arrSize !== false) { if ($arrSize[0] == $arrSettings[0]['width'] && $arrSize[1] == $arrSettings[0]['height']) { //*** Skip image resize. $blnResize = false; } } } //*** Resize the image. if ($blnResize) { $intQuality = empty($arrSettings[0]['quality']) ? 75 : $arrSettings[0]['quality']; ImageResizer::resize($_PATHS['upload'] . $localValues[$subkey], $arrSettings[0]['width'], $arrSettings[0]['height'], $arrSettings[0]['scale'], $intQuality, true, NULL, false, $arrSettings[0]['grayscale']); } } } //*** Move file to remote server. if (!$objMultiUpload->moveToFTP($strServer, $strUsername, $strPassword, $strRemoteFolder)) { $strMessage = $objLang->get("moveToFTP", "alert"); $fileValue = $cacheFileValue; } } else { $strMessage = $objMultiUpload->errorMessage() . "<br />"; $strMessage .= "Files: " . $objMultiUpload->getTotalFiles() . " and Success: " . $objMultiUpload->getSuccessFiles(); } } $strValue = $fileValue; break; case FIELD_TYPE_BOOLEAN: if ($strValue == "1") { $strValue = "true"; } if (empty($strValue)) { $strValue = "false"; } break; } $objValue = $objField->getNewValueObject(); $objValue->setValue($strValue); $objValue->setLanguageId($objContentLanguage->getId()); $objValue->setCascade($blnCascade ? 1 : 0); $objField->setValueObject($objValue); } } } //*** Feed Fields. if (substr($key, 0, 4) == "tpf_") { //*** Get the template Id from the request $intTemplateFieldId = substr($key, 4); //*** Is the Id really an Id? if (is_numeric($intTemplateFieldId)) { //*** Get the cascade value for the currentfield. $arrCascades = explode(",", request("efv_{$intTemplateFieldId}_cascades")); //*** Loop through the languages to insert the value by language. $objContentLangs = ContentLanguage::select(); foreach ($objContentLangs as $objContentLanguage) { //*** Insert the value by language. in_array($objContentLanguage->getId(), $arrCascades) ? $blnCascade = true : ($blnCascade = false); $strValue = request("tpf_{$intTemplateFieldId}_{$objContentLanguage->getId()}"); $objFeedField = new ElementFieldFeed(); $objFeedField->setElementId($objElement->getId()); $objFeedField->setTemplateFieldId($intTemplateFieldId); $objFeedField->setFeedPath(str_replace("----", "/", $strValue)); $objFeedField->setXpath(str_replace("----", "/", $strValue)); $objFeedField->setLanguageId($objContentLanguage->getId()); $objFeedField->setCascade($blnCascade ? 1 : 0); $objFeedField->save(); } } } } //*** Remove deleted files. $objFtp = new FTP($strServer, NULL, NULL, true); $objFtp->login($strUsername, $strPassword); $objFtp->pasv(true); foreach ($arrFieldCache as $intTemplateFieldId => $arrLanguage) { foreach ($arrLanguage as $strValue) { $arrValues = explode("\n", $strValue); foreach ($arrValues as $value) { if (!empty($value)) { //*** Find file name. $arrFile = explode(":", $value); if (count($arrFile) > 1 && count($arrFile) < 3) { //*** Check if the file is used by other elements. if (!ElementField::fileHasDuplicates($value)) { //*** Remove file. $strFile = $strRemoteFolder . $arrFile[1]; $objFtp->delete($strFile); //*** Resized variations? $objImageField = new ImageField($intTemplateFieldId); $arrSettings = $objImageField->getSettings(); foreach ($arrSettings as $key => $arrSetting) { if (!empty($arrSetting['width']) || !empty($arrSetting['height'])) { //*** Remove file. $strFile = $strRemoteFolder . FileIO::add2Base($arrFile[1], $arrSetting['key']); $objFtp->delete($strFile); } } } } } } } } //*** Update the search index. $objSearch = new Search(); $objSearch->updateIndex($objElement->getId()); //*** Clear cache if caching enabled. $objElement->clearCache($objFtp); $objElement->clearZeroCache($objFtp); } else { //*** Activate all languages for the folder type. $objContentLangs = ContentLanguage::select(); foreach ($objContentLangs as $objContentLanguage) { $objElement->setLanguageActive($objContentLanguage->getId(), true); } } //*** Redirect the page. if (empty($strMessage)) { $intForward = $objElement->getParentId(); $varCmd = CMD_LIST; $intForwardToElement = null; $varValue = Setting::getValueByName("edit_after_save"); if ($varValue && $strCommand == CMD_ADD) { $intForwardToElement = $objElement->getId(); $varCmd = CMD_EDIT; } else { if (Setting::getValueByName('next_after_save') && $intForward > 0) { //*** Try to get first child element if (Setting::getValueByName("next_is_child")) { $objChildren = $objElement->getElements(); if (is_object($objChildren) && $objChildren->count() > 0) { $objChild = $objChildren->current(); $intForwardToElement = $objChild->getId(); if ($intForwardToElement > 0) { $varCmd = CMD_EDIT; } } } //*** Get next sibling $objParent = Element::selectByPK($objElement->getParentId()); $objChildren = $objParent->getElements(); $blnBreak = false; if (is_object($objChildren) && is_null($intForwardToElement)) { foreach ($objChildren as $objChild) { if ($blnBreak) { $intForwardToElement = $objChild->getId(); $varCmd = CMD_EDIT; break; } if ($objElement->getId() == $objChild->getId()) { $blnBreak = true; } } } } } if (!empty($intForwardToElement) && $intForwardToElement !== 0) { $intForward = $intForwardToElement; } header("Location: " . Request::getUri() . "/?cid=" . $_POST["cid"] . "&cmd=" . $varCmd . "&eid=" . $intForward); exit; } else { $_SESSION['uiError'] = $strMessage; header("Location: " . Request::getUri() . "/?cid=" . $_POST["cid"] . "&cmd=" . CMD_EDIT . "&eid=" . $objElement->getId() . "&err=1"); exit; } } } //*** Parse the page. $objElement = Element::selectByPK($intElmntId); //*** Errors. if ($blnUiError) { $objTpl->setCurrentBlock("error-main"); $objTpl->setVariable("ERROR_MAIN", $_SESSION['uiError']); $objTpl->parseCurrentBlock(); } //*** Render the template pulldown. if ($blnIsFolder) { $objTpl->setCurrentBlock("headertitel_simple"); $objTpl->setVariable("HEADER_TITLE", $objLang->get("details", "label")); $objTpl->parseCurrentBlock(); $objTemplates = NULL; } else { $objTpl->setCurrentBlock("headertitel_simple"); $objTpl->setVariable("HEADER_TITLE", $objLang->get("details", "label")); $objTpl->parseCurrentBlock(); if (is_object($objElement)) { if ($strCommand == CMD_EDIT) { $objTemplate = Template::selectByPK($objElement->getTemplateId()); $objTemplates = new DBA__Collection(); $objTemplates->addObject($objTemplate); } else { $objTemplates = $objElement->getSubTemplates(); } } else { $strSql = sprintf("SELECT * FROM pcms_template WHERE parentId = '0' AND accountId = '%s'", $_CONF['app']['account']->getId()); $objTemplates = Template::select($strSql); } } if (is_object($objTemplates)) { foreach ($objTemplates as $objTemplate) { $objTpl->setCurrentBlock("list_template"); $objTpl->setVariable("TEMPLATELIST_VALUE", $objTemplate->getId()); $objTpl->setVariable("TEMPLATELIST_TEXT", $objTemplate->getName()); $objTpl->parseCurrentBlock(); } //*** Render fields if there is only one template. if ($objTemplates->count() == 1 || $strCommand == CMD_EDIT) { $strLanguageBlock = $blnIsDynamic ? "feed.list_language" : "list_language"; $intDefaultLanguage = ContentLanguage::getDefault()->getId(); $intSelectLanguage = $intDefaultLanguage; $objContentLangs = ContentLanguage::select(); foreach ($objContentLangs as $objContentLanguage) { $objTpl->setCurrentBlock($strLanguageBlock); $objTpl->setVariable("LANGUAGELIST_VALUE", $objContentLanguage->getId()); if ($intDefaultLanguage == $objContentLanguage->getId()) { $objTpl->setVariable("LANGUAGELIST_TEXT", $objContentLanguage->getName() . " (" . $objLang->get("default", "label") . ")"); } else { $objTpl->setVariable("LANGUAGELIST_TEXT", $objContentLanguage->getName()); } if ($intSelectLanguage == $objContentLanguage->getId()) { $objTpl->setVariable("LANGUAGELIST_SELECTED", " selected=\"selected\""); } $objTpl->parseCurrentBlock(); } $objTemplates->rewind(); $objFields = $objTemplates->current()->getFields(); $objTpl->setVariable("LABEL_ELEMENT_FIELDS", $objLang->get("elementFields", "label")); $strFields = ""; if (!$blnIsDynamic) { foreach ($objFields as $objField) { $objFieldTpl = new HTML_Template_ITX($_PATHS['templates']); $objFieldTpl->loadTemplatefile("elementfield.tpl.htm"); //*** Get the field value from the element. $strValue = ""; if (is_object($objElement)) { $strValue = $objElement->getValueByTemplateField($objField->getId()); } $strDescription = $objField->getDescription(); //*** Get the field type object. $objType = TemplateFieldType::selectByPK($objField->getTypeId()); $intMaxFileCount = null; switch ($objField->getTypeId()) { case FIELD_TYPE_DATE: $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.date', 'elementfield_date.tpl.htm'); foreach ($objContentLangs as $objContentLanguage) { $objFieldTpl->setCurrentBlock("field.{$objType->getInput()}.value"); $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}"); if (is_object($objElement)) { $strValue = $objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId(), true); $strValue = Date::fromMysql($_CONF['app']['universalDate'], $strValue); } else { $strValue = ""; } $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", htmlspecialchars($strValue)); $objFieldTpl->parseCurrentBlock(); } $objValue = $objField->getValueByName("tfv_field_format"); $strFormatValue = is_object($objValue) ? $objValue->getValue() : ""; $objFieldTpl->setCurrentBlock("field.date"); $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}"); if ($objField->getRequired()) { $objFieldTpl->setVariable("FIELD_REQUIRED", "* "); } $objFieldTpl->setVariable("FIELD_DATE_FORMAT", $strFormatValue); $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName())); if (is_object($objElement)) { $objElementField = $objElement->getFieldByTemplateField($objField->getId()); if (is_object($objElementField)) { $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades())); } } if (!empty($strDescription)) { $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription()); } $objFieldTpl->parseCurrentBlock(); break; case FIELD_TYPE_LARGETEXT: $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.simpletext', 'elementfield_textarea.tpl.htm'); foreach ($objContentLangs as $objContentLanguage) { $objFieldTpl->setCurrentBlock("field.simpletext.value"); $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}"); if (is_object($objElement)) { $strValue = htmlspecialchars($objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId())); } else { $strValue = ""; } $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue); $objFieldTpl->parseCurrentBlock(); } //*** Calculate and set the textarea height. $minHeight = 115; $maxHeight = 400; $intHeight = $minHeight; $objValue = $objField->getValueByName("tfv_field_max_characters"); $strMaxChar = is_object($objValue) ? $objValue->getValue() : ""; if (!empty($strMaxChar) && is_numeric($strMaxChar)) { $intHeight = ($strMaxChar - 500) * 0.05 + $minHeight; if ($intHeight < $minHeight) { $intHeight = $minHeight; } if ($intHeight > $maxHeight) { $intHeight = $maxHeight; } } $objFieldTpl->setCurrentBlock("field.simpletext"); $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}"); $objFieldTpl->setVariable("FIELD_HEIGHT", "{$intHeight}px"); if ($objField->getRequired()) { $objFieldTpl->setVariable("FIELD_REQUIRED", "* "); } $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName())); if (!empty($strDescription)) { $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription()); } if (is_object($objElement)) { $objElementField = $objElement->getFieldByTemplateField($objField->getId()); if (is_object($objElementField)) { $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades())); } } $objFieldTpl->parseCurrentBlock(); break; case FIELD_TYPE_SELECT_LIST_SINGLE: case FIELD_TYPE_SELECT_LIST_MULTI: if ($objField->getTypeId() == FIELD_TYPE_SELECT_LIST_SINGLE) { $objDefaultValue = $objField->getValueByName("tfv_list_default"); $objValue = $objField->getValueByName("tfv_list_value"); $strFieldClass = "select-one"; $strMultiple = ""; } else { $objDefaultValue = $objField->getValueByName("tfv_multilist_default"); $objValue = $objField->getValueByName("tfv_multilist_value"); $strFieldClass = "select-multiple"; $strMultiple = "multiple=\"multiple\""; } $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.select', 'elementfield_selectlist.tpl.htm'); $strTemplValue = is_object($objDefaultValue) ? $objDefaultValue->getValue() : ""; foreach ($objContentLangs as $objContentLanguage) { $objFieldTpl->setCurrentBlock("field.select.value"); $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}"); //*** Determine the selected value for the list. if (is_object($objElement)) { $strValue = $objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId()); } else { $strValue = NULL; } if (!empty($strValue) || !is_null($strValue)) { //*** Do Nothing. } elseif (!empty($strTemplValue)) { $strValue = $strTemplValue; } $arrDefaultValue = explode("\n", $strValue); $arrValue = array(); foreach ($arrDefaultValue as $value) { $value = trim($value); if (!empty($value)) { array_push($arrValue, $value); } } $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", implode(",", $arrValue)); $objFieldTpl->parseCurrentBlock(); } //*** Render options for the list. $strListValue = is_object($objValue) ? $objValue->getValue() : ""; $arrValues = explode("\n", $strListValue); foreach ($arrValues as $value) { if (!empty($value)) { //*** Determine if we have a label. $arrValue = explode(":", $value); if (count($arrValue) > 1) { $optionLabel = trim($arrValue[0]); $optionValue = trim($arrValue[1]); } else { $optionLabel = trim($value); $optionValue = trim($value); } $objFieldTpl->setCurrentBlock("field.select.option"); $objFieldTpl->setVariable("FIELD_VALUE", $optionValue); $objFieldTpl->setVariable("FIELD_TEXT", xhtmlsave($optionLabel)); $objFieldTpl->parseCurrentBlock(); } } $objFieldTpl->setCurrentBlock("field.select"); $objFieldTpl->setVariable("FIELD_SELECT_SIZE", 1); $objFieldTpl->setVariable("FIELD_CLASS", $strFieldClass); $objFieldTpl->setVariable("FIELD_MULTIPLE", $strMultiple); $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}"); if ($objField->getRequired()) { $objFieldTpl->setVariable("FIELD_REQUIRED", "* "); } $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName())); if (!empty($strDescription)) { $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription()); } if (is_object($objElement)) { $objElementField = $objElement->getFieldByTemplateField($objField->getId()); if (is_object($objElementField)) { $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades())); } } $objFieldTpl->parseCurrentBlock(); break; case FIELD_TYPE_CHECK_LIST_SINGLE: case FIELD_TYPE_CHECK_LIST_MULTI: if ($objField->getTypeId() == FIELD_TYPE_CHECK_LIST_SINGLE) { $objDefaultValue = $objField->getValueByName("tfv_list_default"); $objValue = $objField->getValueByName("tfv_list_value"); $strType = "radio"; } else { $objDefaultValue = $objField->getValueByName("tfv_multilist_default"); $objValue = $objField->getValueByName("tfv_multilist_value"); $strType = "checkbox"; } $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.check', 'elementfield_checklist.tpl.htm'); $strTemplValue = is_object($objDefaultValue) ? $objDefaultValue->getValue() : ""; foreach ($objContentLangs as $objContentLanguage) { $objFieldTpl->setCurrentBlock("field.check.value"); $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}"); //*** Determine the selected value for the list. if (is_object($objElement)) { $strValue = $objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId()); } else { $strValue = NULL; } if (!empty($strValue) || !is_null($strValue)) { //*** Do Nothing. } elseif (!empty($strTemplValue)) { $strValue = $strTemplValue; } $arrDefaultValue = explode("\n", $strValue); $arrValue = array(); foreach ($arrDefaultValue as $value) { $value = trim($value); if (!empty($value)) { array_push($arrValue, $value); } } $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", implode(",", $arrValue)); $objFieldTpl->parseCurrentBlock(); } //*** Render options for the list. $strListValue = is_object($objValue) ? $objValue->getValue() : ""; $arrValues = explode("\n", $strListValue); $intCount = 0; foreach ($arrValues as $value) { if (!empty($value)) { //*** Determine if we have a label. $arrValue = explode(":", $value); if (count($arrValue) > 1) { $optionLabel = trim($arrValue[0]); $optionValue = trim($arrValue[1]); } else { $optionLabel = trim($value); $optionValue = trim($value); } $objFieldTpl->setCurrentBlock("field.check.item"); $objFieldTpl->setVariable("SUBFIELD_TYPE", $strType); $objFieldTpl->setVariable("SUBFIELD_VALUE", $optionValue); $objFieldTpl->setVariable("SUBFIELD_TEXT", $optionLabel); $objFieldTpl->setVariable("SUBFIELD_ID", "efv_{$objField->getId()}_sub_{$intCount}"); $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}"); $objFieldTpl->parseCurrentBlock(); $intCount++; } } $objFieldTpl->setCurrentBlock("field.list"); $objFieldTpl->setVariable("SUBFIELD_TYPE", $strType); $objFieldTpl->parseCurrentBlock(); $objFieldTpl->setCurrentBlock("field.check"); $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}"); if ($objField->getRequired()) { $objFieldTpl->setVariable("FIELD_REQUIRED", "* "); } $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName())); if (!empty($strDescription)) { $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription()); } if (is_object($objElement)) { $objElementField = $objElement->getFieldByTemplateField($objField->getId()); if (is_object($objElementField)) { $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades())); } } $objFieldTpl->parseCurrentBlock(); break; case FIELD_TYPE_IMAGE: $objValue = $objField->getValueByName('tfv_image_count'); $intMaxFileCount = is_object($objValue) ? $objValue->getValue() : 10000; $strCurrentTitle = $objLang->get("imagesCurrent", "label"); $strNewTitle = $objLang->get("imagesNew", "label"); $strThumbPath = Setting::getValueByName("web_server") . Setting::getValueByName("file_folder"); $strUploadPath = Request::getURI() . $_CONF['app']['baseUri'] . "files/"; case FIELD_TYPE_FILE: if (!isset($intMaxFileCount)) { $objValue = $objField->getValueByName('tfv_file_count'); $intMaxFileCount = is_object($objValue) ? $objValue->getValue() : 10000; $strCurrentTitle = $objLang->get("filesCurrent", "label"); $strNewTitle = $objLang->get("filesNew", "label"); $strThumbPath = Setting::getValueByName("web_server") . Setting::getValueByName("file_folder"); $strUploadPath = Request::getURI() . $_CONF['app']['baseUri'] . "files/"; } if (is_object($objElement)) { $objElementField = $objElement->getFieldByTemplateField($objField->getId()); } $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.file', 'elementfield_file.tpl.htm'); foreach ($objContentLangs as $objContentLanguage) { if (is_object($objElement)) { $strValue = $objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId(), true); } else { $strValue = ""; } $intFileCount = 0; if (!empty($strValue)) { $arrValues = explode("\n", $strValue); foreach ($arrValues as $value) { if (!empty($value)) { $arrValue = explode(":", $value); if (count($arrValue) > 1) { $strValue = $arrValue[1]; $strLabel = $arrValue[0]; //*** Media library item? if (count($arrValue) > 2) { $strValue = $arrValue[1] . ":" . $arrValue[2]; } } else { $strValue = $arrValue[0]; $strLabel = $arrValue[0]; } $intFileCount++; $objFieldTpl->setCurrentBlock("field.file.edit"); $objFieldTpl->setVariable("FIELD_LANGUAGE_ID_COUNT", "efv_{$objField->getId()}_{$objContentLanguage->getId()}_{$intFileCount}"); $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}"); $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", "{$strLabel}:{$strValue}"); $objFieldTpl->parseCurrentBlock(); } } } $objFieldTpl->setCurrentBlock("field.file.value"); $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}"); $objFieldTpl->setVariable("FIELD_LANGUAGE_CURRENT_FILES", $intFileCount); $objFieldTpl->setVariable("FIELD_LANGUAGE_ALTTEXT_VALUE", ""); $objFieldTpl->parseCurrentBlock(); } $intFileCount = 0; if (!empty($strValue)) { $arrValues = explode("\n", $strValue); foreach ($arrValues as $value) { if (!empty($value)) { $arrValue = explode(":", $value); if (count($arrValue) > 1) { $strValue = $arrValue[1]; $strLabel = $arrValue[0]; } else { $strValue = $arrValue[0]; $strLabel = $arrValue[0]; } if ($objField->getTypeId() == FIELD_TYPE_IMAGE) { $objFieldTpl->setCurrentBlock("thumbnail"); $objFieldTpl->setVariable("FIELD_ORIGINAL_VALUE", $strLabel); $objFieldTpl->setVariable("FIELD_VALUE", $strValue); $objFieldTpl->parseCurrentBlock(); } $objFieldTpl->setCurrentBlock("field.{$objType->getInput()}.edit"); $objFieldTpl->setVariable("FIELD_FILE_ID", "efv_{$objField->getId()}"); $objFieldTpl->setVariable("FIELD_ORIGINAL_VALUE", $strLabel); $objFieldTpl->setVariable("FIELD_VALUE", $strValue); $objFieldTpl->parseCurrentBlock(); $intFileCount++; } } } //*** Parse the rest of the block. $objFieldTpl->setCurrentBlock("field.file.select-type.library"); $objFieldTpl->setVariable("LABEL_LIBRARY", $objLang->get("pcmsInlineStorage", "menu")); $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}"); $objFieldTpl->parseCurrentBlock(); $objFieldTpl->setCurrentBlock("field.file.select-type.upload"); $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}"); $objFieldTpl->parseCurrentBlock(); $objFieldTpl->setCurrentBlock("field.file"); $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}"); if ($objField->getRequired()) { $objFieldTpl->setVariable("FIELD_REQUIRED", "* "); } $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName())); $objFieldTpl->setVariable("FIELD_BROWSE_NAME", $objLang->get("browseImage", "label")); //$objFieldTpl->setVariable("FIELD_ALT_NAME", $objLang->get("altImage", "label")); $objFieldTpl->setVariable("FIELD_CURRENT_FILES", $intFileCount); $objFieldTpl->setVariable("FIELD_MAX_FILES", $intMaxFileCount); $objFieldTpl->setVariable("FIELD_THUMB_PATH", $strThumbPath); $objFieldTpl->setVariable("FIELD_UPLOAD_PATH", $strUploadPath); $objFieldTpl->setVariable("FIELD_MAX_CHAR", 60); $objFieldTpl->setVariable("STORAGE_ITEMS", StorageItems::getFolderListHTML()); $objFieldTpl->setVariable("LABEL_CHOOSE_FOLDER", $objLang->get("chooseFolder", "label")); $objFieldTpl->setVariable("FIELD_HEADER_CURRENT", $strCurrentTitle); $objFieldTpl->setVariable("FIELD_HEADER_NEW", $strNewTitle); $objFieldTpl->setVariable("FIELD_LABEL_REMOVE", $objLang->get("delete", "button")); $objFieldTpl->setVariable("FIELD_LABEL_CANCEL", strtolower($objLang->get("cancel", "button"))); $objFieldTpl->setVariable("FIELD_LABEL_ALT", $objLang->get("alttag", "button")); if (!empty($strDescription)) { $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription()); } if (is_object($objElementField)) { $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades())); } if ($objField->getTypeId() == FIELD_TYPE_FILE) { $objValue = $objField->getValueByName("tfv_file_extension"); $strExtensions = is_object($objValue) ? $objValue->getValue() : ""; if (!empty($strExtensions)) { $strExtensions = str_replace("%s", Setting::getValueByName('file_upload_extensions'), $strExtensions); } else { $strExtensions = strtolower(Setting::getValueByName('file_upload_extensions')); } } else { $strExtensions = strtolower(Setting::getValueByName('image_upload_extensions')); } $objFieldTpl->setVariable("FIELD_FILE_TYPE", "*" . implode("; *", explode(" ", $strExtensions))); $objFieldTpl->parseCurrentBlock(); break; case FIELD_TYPE_SMALLTEXT: case FIELD_TYPE_NUMBER: case FIELD_TYPE_LINK: $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.text', 'elementfield_text.tpl.htm'); foreach ($objContentLangs as $objContentLanguage) { $objFieldTpl->setCurrentBlock("field.text.value"); $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}"); if (is_object($objElement)) { $strValue = htmlspecialchars($objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId())); } else { $strValue = ""; } $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue); $objFieldTpl->parseCurrentBlock(); if ($objField->getTypeId() == FIELD_TYPE_LINK) { $objFieldTpl->setCurrentBlock("field.text.elementvalue"); $objFieldTpl->setVariable("FIELD_ELEMENT_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}"); $objFieldTpl->setVariable("ELEMENT_FIELD_ID", "efv_{$objField->getId()}"); $objFieldTpl->setVariable("FIELD_CLASS", "deeplink"); $elementTrail = Element::generateElementTrailString($strValue); $objFieldTpl->setVariable("FIELD_ELEMENT_VALUE", htmlentities($elementTrail)); $objFieldTpl->parseCurrentBlock(); } } $objFieldTpl->setCurrentBlock("field.text"); $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}"); if ($objField->getRequired()) { $objFieldTpl->setVariable("FIELD_REQUIRED", "* "); } $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName())); if (!empty($strDescription)) { $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription()); } if (is_object($objElement)) { $objElementField = $objElement->getFieldByTemplateField($objField->getId()); if (is_object($objElementField)) { $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades())); } } $objFieldTpl->parseCurrentBlock(); break; case FIELD_TYPE_MOVABLECANVAS_COORDINATES: $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.mccoordinates', 'elementfield_mccoordinates.tpl.htm'); foreach ($objContentLangs as $objContentLanguage) { $objFieldTpl->setCurrentBlock("field.mccoordinates.value"); $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}"); if (is_object($objElement)) { $strValue = htmlspecialchars($objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId())); } else { $strValue = ""; } $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue); $objFieldTpl->parseCurrentBlock(); } $objFieldTpl->setCurrentBlock("field.mccoordinates"); $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}"); if ($objField->getRequired()) { $objFieldTpl->setVariable("FIELD_REQUIRED", "* "); } $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName())); if (!empty($strDescription)) { $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription()); } $objFieldTpl->setVariable("MC-API-ID", $objField->getValueByName("tfv_field_api_key")->getValue()); $objFieldTpl->setVariable("MC-MAP-ID", $objField->getValueByName("tfv_field_map_key")->getValue()); if (is_object($objElement)) { $objElementField = $objElement->getFieldByTemplateField($objField->getId()); if (is_object($objElementField)) { $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades())); } } $objFieldTpl->parseCurrentBlock(); break; case FIELD_TYPE_SIMPLETEXT: $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.simpletext', 'elementfield_simpletext.tpl.htm'); foreach ($objContentLangs as $objContentLanguage) { $objFieldTpl->setCurrentBlock("field.simpletext.value"); $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}"); if (is_object($objElement)) { $strValue = htmlspecialchars($objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId())); } else { $strValue = ""; } $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue); $objFieldTpl->parseCurrentBlock(); } //*** Calculate and set the textarea height. $minHeight = 115; $maxHeight = 400; $intHeight = $minHeight; $objValue = $objField->getValueByName("tfv_field_max_characters"); $strMaxChar = is_object($objValue) ? $objValue->getValue() : ""; if (!empty($strMaxChar) && is_numeric($strMaxChar)) { $intHeight = ($strMaxChar - 500) * 0.05 + $minHeight; if ($intHeight < $minHeight) { $intHeight = $minHeight; } if ($intHeight > $maxHeight) { $intHeight = $maxHeight; } } $objFieldTpl->setCurrentBlock("field.simpletext"); $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}"); $objFieldTpl->setVariable("FIELD_HEIGHT", "{$intHeight}px"); if ($objField->getRequired()) { $objFieldTpl->setVariable("FIELD_REQUIRED", "* "); } $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName())); if (!empty($strDescription)) { $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription()); } if (is_object($objElement)) { $objElementField = $objElement->getFieldByTemplateField($objField->getId()); if (is_object($objElementField)) { $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades())); } } $objFieldTpl->parseCurrentBlock(); break; case FIELD_TYPE_USER: $strFieldClass = "select-one"; $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.select', 'elementfield_selectlist.tpl.htm'); foreach ($objContentLangs as $objContentLanguage) { $objFieldTpl->setCurrentBlock("field.select.value"); $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}"); //*** Determine the selected value for the list. if (is_object($objElement)) { $strValue = $objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId()); } else { $strValue = ""; } $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue); $objFieldTpl->parseCurrentBlock(); } //*** Render options for the list. global $objLiveAdmin; $filters = array('container' => 'auth', 'filters' => array('account_id' => array($_CONF['app']['account']->getId()))); $objUsers = $objLiveAdmin->getUsers($filters); if (is_array($objUsers)) { foreach ($objUsers as $objUser) { $objFieldTpl->setCurrentBlock("field.select.option"); $objFieldTpl->setVariable("FIELD_VALUE", $objUser["perm_user_id"]); $objFieldTpl->setVariable("FIELD_TEXT", xhtmlsave($objUser["handle"])); $objFieldTpl->parseCurrentBlock(); } } $objFieldTpl->setCurrentBlock("field.select"); $objFieldTpl->setVariable("FIELD_SELECT_SIZE", 1); $objFieldTpl->setVariable("FIELD_CLASS", $strFieldClass); $objFieldTpl->setVariable("FIELD_MULTIPLE", ""); $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}"); if ($objField->getRequired()) { $objFieldTpl->setVariable("FIELD_REQUIRED", "* "); } $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName())); if (!empty($strDescription)) { $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription()); } if (is_object($objElement)) { $objElementField = $objElement->getFieldByTemplateField($objField->getId()); if (is_object($objElementField)) { $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades())); } } $objFieldTpl->parseCurrentBlock(); break; case FIELD_TYPE_BOOLEAN: $objDefaultValue = $objField->getValueByName("tfv_boolean_default"); $strTemplValue = is_object($objDefaultValue) ? $objDefaultValue->getValue() : ""; $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.checkbox', 'elementfield_checkbox.tpl.htm'); foreach ($objContentLangs as $objContentLanguage) { $objFieldTpl->setCurrentBlock("field.checkbox.value"); $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}"); if (is_object($objElement)) { $strValue = $objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId()); } else { $strValue = NULL; } if (!empty($strValue) || !is_null($strValue)) { //*** Do Nothing. } elseif (!empty($strTemplValue)) { $strValue = $strTemplValue; } $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue); $objFieldTpl->parseCurrentBlock(); } $objFieldTpl->setCurrentBlock("field.checkbox"); $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}"); if ($objField->getRequired()) { $objFieldTpl->setVariable("FIELD_REQUIRED", "* "); } $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName())); $objFieldTpl->setVariable("FIELD_VALUE", $strValue); if (!empty($strDescription)) { $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription()); } if (is_object($objElement)) { $objElementField = $objElement->getFieldByTemplateField($objField->getId()); if (is_object($objElementField)) { $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades())); } } $objFieldTpl->parseCurrentBlock(); break; } $strFields .= $objFieldTpl->get(); } } if (!empty($strFields)) { $objTpl->setVariable("ELEMENT_FIELDS", $strFields); } if (!$blnIsDynamic) { $objTpl->setVariable("LABEL_LANGUAGE", $objLang->get("language", "form")); $objTpl->setVariable("ACTIVE_LANGUAGE", $intDefaultLanguage); $objTpl->setVariable("DEFAULT_LANGUAGE", $intDefaultLanguage); } else { $objTpl->setCurrentBlock("feedlanguage"); $objTpl->setVariable("LABEL_LANGUAGE", $objLang->get("language", "form")); $objTpl->setVariable("ACTIVE_LANGUAGE", $intDefaultLanguage); $objTpl->setVariable("DEFAULT_LANGUAGE", $intDefaultLanguage); $objTpl->parseCurrentBlock(); } //*** Meta tab. if (is_object($objElement) && $objElement->isPage()) { $objTpl->setCurrentBlock("meta-title"); $objTpl->setVariable("HEADER", $objLang->get("meta", "label")); $objTpl->parseCurrentBlock(); $objTpl->setCurrentBlock("description-meta"); $objTpl->setVariable("LABEL", $objLang->get("metaInfo", "form")); $objTpl->parseCurrentBlock(); //*** Meta specific labels $objTpl->setVariable("LABEL_META_ALIAS", $objLang->get("alias", "form")); $objTpl->setVariable("LABEL_META_TITLE", $objLang->get("metaTitle", "label")); $objTpl->setVariable("LABEL_META_KEYWORDS", $objLang->get("metaKeywords", "label")); $objTpl->setVariable("LABEL_META_DESCRIPTION", $objLang->get("metaDescription", "label")); $objTpl->setVariable("META_KEYWORDS_NOTE", $objLang->get("metaKeywords", "tip")); $objTpl->setVariable("META_DESCRIPTION_NOTE", $objLang->get("metaDescription", "tip")); $objTpl->setVariable("META_ALIAS_NOTE", $objLang->get("alias", "tip")); $objTpl->setVariable("ACTIVE_META_LANGUAGE", $intSelectLanguage); $objTpl->setVariable("DEFAULT_META_LANGUAGE", $intDefaultLanguage); $objTpl->setVariable("LABEL_META_LANGUAGE", $objLang->get("language", "form")); //*** Meta languages $objContentLangs = ContentLanguage::select(); foreach ($objContentLangs as $objContentLanguage) { $objTpl->setCurrentBlock("list_meta-language"); $objTpl->setVariable("LANGUAGELIST_VALUE", $objContentLanguage->getId()); if ($intDefaultLanguage == $objContentLanguage->getId()) { $objTpl->setVariable("LANGUAGELIST_TEXT", $objContentLanguage->getName() . " (" . $objLang->get("default", "label") . ")"); } else { $objTpl->setVariable("LANGUAGELIST_TEXT", $objContentLanguage->getName()); } if ($intSelectLanguage == $objContentLanguage->getId()) { $objTpl->setVariable("LANGUAGELIST_SELECTED", " selected=\"selected\""); } $objTpl->parseCurrentBlock(); } //*** Meta language values. foreach ($objContentLangs as $objContentLanguage) { $strValue = $strCommand != CMD_ADD ? $objElement->getAlias($objContentLanguage->getId()) : ''; $objTpl->setCurrentBlock("field.meta_alias.value"); $objTpl->setVariable("FIELD_ALIAS_ID", "frm_meta_alias_{$objContentLanguage->getId()}"); $objTpl->setVariable("FIELD_ALIAS_VALUE", $strValue); $objTpl->parseCurrentBlock(); $objMeta = is_object($objElement) && $strCommand != CMD_ADD ? $objElement->getMeta($objContentLanguage->getId()) : NULL; $strValue = is_object($objMeta) ? $objMeta->getValueByValue("name", "title") : ""; $objTpl->setCurrentBlock("field.meta_title.value"); $objTpl->setVariable("FIELD_LANGUAGE_ID", "frm_meta_title_{$objContentLanguage->getId()}"); $objTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue); $objTpl->parseCurrentBlock(); $strValue = is_object($objMeta) ? $objMeta->getValueByValue("name", "keywords") : ""; $objTpl->setCurrentBlock("field.meta_keywords.value"); $objTpl->setVariable("FIELD_LANGUAGE_ID", "frm_meta_keywords_{$objContentLanguage->getId()}"); $objTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue); $objTpl->parseCurrentBlock(); $strValue = is_object($objMeta) ? $objMeta->getValueByValue("name", "description") : ""; $objTpl->setCurrentBlock("field.meta_description.value"); $objTpl->setVariable("FIELD_LANGUAGE_ID", "frm_meta_description_{$objContentLanguage->getId()}"); $objTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue); $objTpl->parseCurrentBlock(); } //*** Meta language cascades. if ($strCommand != CMD_ADD) { $objTpl->setVariable("META_ALIAS_CASCADES", implode(",", Alias::getCascades($objElement->getId()))); $objTpl->setVariable("META_TITLE_CASCADES", implode(",", ElementMeta::getCascades($objElement->getId(), "title"))); $objTpl->setVariable("META_KEYWORDS_CASCADES", implode(",", ElementMeta::getCascades($objElement->getId(), "keywords"))); $objTpl->setVariable("META_DESCRIPTION_CASCADES", implode(",", ElementMeta::getCascades($objElement->getId(), "description"))); } } } //*** Feeds if dynamic. if ($blnIsDynamic) { if ($strCommand == CMD_EDIT) { $objElementFeed = $objElement->getFeed(); $objFeed = Feed::selectByPK($objElementFeed->getFeedId()); $objFeeds = new DBA__Collection(); $objFeeds->addObject($objFeed); $objParent = Element::selectByPK($objElement->getParentId()); } else { $objFeeds = Feed::select(); $objParent = Element::selectByPK($intElmntId); } if (isset($objParent) && $objParent->getTypeId() == ELM_TYPE_DYNAMIC) { $objNodes = $objParent->getFeed()->getStructuredNodes(); $objTpl->setCurrentBlock("list_feedpath"); $objTpl->setVariable("VALUE", ""); $objTpl->setVariable("TEXT", "Basepath"); $objTpl->parseCurrentBlock(); $objTpl->setCurrentBlock("list_feedpath"); $objTpl->setVariable("VALUE", ""); $objTpl->setVariable("TEXT", "-------------"); $objTpl->parseCurrentBlock(); if (count($objNodes) > 0) { foreach ($objNodes as $objSubElement) { $objTpl->setCurrentBlock("list_feedpath"); $objTpl->setVariable("VALUE", $objSubElement->getName()); $objTpl->setVariable("TEXT", $objSubElement->getName()); $objTpl->parseCurrentBlock(); } } } else { if (is_object($objFeeds)) { foreach ($objFeeds as $objFeed) { $objTpl->setCurrentBlock("list_feed"); $objTpl->setVariable("FEEDLIST_VALUE", $objFeed->getId()); $objTpl->setVariable("FEEDLIST_TEXT", $objFeed->getName()); $objTpl->parseCurrentBlock(); } } } if ($strCommand == CMD_EDIT) { $blnDynamicAlias = false; $objFeedFields = $objElementFeed->getStructuredNodes(); foreach ($objFeedFields as $objFeedField) { $objTpl->setCurrentBlock("list_feed_field"); $objTpl->setVariable("FEEDLIST_VALUE", $objFeedField->getName()); $objTpl->setVariable("FEEDLIST_TEXT", $objFeedField->getName()); if ($objElementFeed->getAliasField() == $objFeedField->getName()) { $objTpl->setVariable("FEEDLIST_SELECTED", "selected=\"selected\""); $blnDynamicAlias = true; } $objTpl->parseCurrentBlock(); } if ($blnDynamicAlias) { $objTpl->setVariable("FORM_DYNAMIC_ALIAS_VALUE", "checked=\"checked\""); } $objTpl->setVariable("FORM_MAXITEMS_VALUE", $objElementFeed->getMaxItems()); //*** Template fields. foreach ($objFields as $objField) { foreach ($objContentLangs as $objContentLanguage) { $objTpl->setCurrentBlock("feed.field.value"); $objTpl->setVariable("FIELD_LANGUAGE_ID", "tpf_{$objField->getId()}_{$objContentLanguage->getId()}"); if (is_object($objElement)) { $strValue = htmlspecialchars($objElement->getFeedValueByTemplateField($objField->getId(), $objContentLanguage->getId())); } else { $strValue = ""; } $objTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue); $objTpl->parseCurrentBlock(); } $objTpl->setCurrentBlock("feed.field"); $objTpl->setVariable("FIELD_ID", "tpf_{$objField->getId()}"); $objTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName())); if (is_object($objElement)) { $objFeedField = $objElement->getFeedFieldByTemplateField($objField->getId()); if (is_object($objFeedField)) { $objTpl->setVariable("FIELD_CASCADES", implode(",", $objFeedField->getCascades())); } } $objTpl->parseCurrentBlock(); } //*** Feed fields. $objFeedFields = $objElementFeed->getStructuredNodes(); $strFields = renderRecursiveFeedFields($objFeedFields); $objTpl->setCurrentBlock("feed.tag"); $objTpl->setVariable("FEEDFIELDS", $strFields); $objTpl->parseCurrentBlock(); } } } //*** Render the element form. $objTpl->setCurrentBlock("description-details"); $objTpl->setVariable("LABEL", $objLang->get("requiredFields", "form")); $objTpl->parseCurrentBlock(); $objTpl->setVariable("LABEL_ACTIVE", $objLang->get("active", "form")); $objTpl->setVariable("LABEL_NAME", $objLang->get("name", "form")); $objTpl->setVariable("LABEL_NOTES", $objLang->get("notes", "form")); //$objTpl->setVariable("LABEL_ALIAS", $objLang->get("alias", "form")); $objTpl->setVariable("APINAME_NOTE", $objLang->get("apiNameNote", "tip")); //$objTpl->setVariable("ALIAS_NOTE", $objLang->get("alias", "tip")); $objTpl->setVariable("LABEL_SAVE", $objLang->get("save", "button")); if (isset($objElement) && $objElement->getTypeId() == ELM_TYPE_LOCKED) { $objTpl->setVariable("DISABLED_SAVE", "disabled=\"disabled\""); } if ($blnIsFolder) { $objTpl->setVariable("LABEL_ELEMENTNAME", $objLang->get("folderName", "form")); $objTpl->setVariable("LABEL_ISPAGE", $objLang->get("pageContainer", "form")); if ($blnError === false && is_object($objElement)) { $objTpl->setVariable("FORM_ISPAGE_VALUE", $objElement->getIsPage() ? "checked=\"checked\"" : ""); } } else { $objTpl->setVariable("LABEL_ELEMENTNAME", $objLang->get("elementName", "form")); $objTpl->setVariable("LABEL_TEMPLATENAME", $objLang->get("template", "form")); if ($blnIsDynamic) { if (isset($objParent) && $objParent->getTypeId() == ELM_TYPE_DYNAMIC) { $objTpl->setVariable("LABEL_FEEDPATH", $objLang->get("basepath", "form")); } else { $objTpl->setVariable("LABEL_FEEDNAME", $objLang->get("feed", "form")); } $objTpl->setVariable("LABEL_MAXITEMS", $objLang->get("maxItems", "form")); } } //*** Predefine schedule variables. $intStartHour = 8; $intStartMinute = 0; $intEndHour = 17; $intEndMinute = 0; //*** Insert values if action is edit. if ($strCommand == CMD_EDIT) { if ($blnError === false) { $objTpl->setVariable("FORM_ACTIVE_VALUE", $objElement->getActive() ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_NAME_VALUE", str_replace("\"", """, $objElement->getName())); $objTpl->setVariable("FORM_APINAME_VALUE", $objElement->getApiname()); //$objTpl->setVariable("FORM_ALIAS_VALUE", $objElement->getAlias()); $objTpl->setVariable("FORM_NOTES_VALUE", $objElement->getDescription()); } $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$objElement->getParentId()}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$objElement->getParentId()}&cmd=" . CMD_LIST); if (!$blnIsFolder && $objElement->getTypeId() != ELM_TYPE_DYNAMIC) { $objTpl->setVariable("ACTIVES_LANGUAGE", implode(",", $objElement->getLanguageActives())); } //*** Publish specific values. $objSchedule = $objElement->getSchedule(); if ($objSchedule->getStartActive()) { $strValue = Date::fromMysql("%d %B %Y", $objSchedule->getStartDate()); $objTpl->setVariable("START_DATE_DISPLAY", empty($strValue) ? " " : $strValue); $objTpl->setVariable("START_DATE_VALUE", Date::fromMysql($_CONF['app']['universalDate'], $objSchedule->getStartDate())); $strValue = Date::fromMysql("%H", $objSchedule->getStartDate()); if (!empty($strValue)) { $intStartHour = $strValue; } $strValue = Date::fromMysql("%M", $objSchedule->getStartDate()); if (!empty($strValue)) { $intStartMinute = $strValue; } $objTpl->setVariable("START_DATE_ACTIVE", "checked=\"checked\""); } else { $objTpl->setVariable("START_DATE_DISPLAY", " "); } if ($objSchedule->getEndActive()) { $strValue = Date::fromMysql("%d %B %Y", $objSchedule->getEndDate()); $objTpl->setVariable("END_DATE_DISPLAY", empty($strValue) ? " " : $strValue); $objTpl->setVariable("END_DATE_VALUE", Date::fromMysql($_CONF['app']['universalDate'], $objSchedule->getEndDate())); $strValue = Date::fromMysql("%H", $objSchedule->getEndDate()); if (!empty($strValue)) { $intEndHour = $strValue; } $strValue = Date::fromMysql("%M", $objSchedule->getEndDate()); if (!empty($strValue)) { $intEndMinute = $strValue; } $objTpl->setVariable("END_DATE_ACTIVE", "checked=\"checked\""); } else { $objTpl->setVariable("END_DATE_DISPLAY", " "); } } else { if ($blnError === false) { if (Setting::getValueByName('elmnt_active_state') == 1) { $objTpl->setVariable("FORM_ACTIVE_VALUE", "checked=\"checked\""); } } $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}&cmd=" . CMD_LIST); //*** Publish specific values. $objTpl->setVariable("START_DATE_DISPLAY", " "); $objTpl->setVariable("END_DATE_DISPLAY", " "); } //*** Render tabs. if (is_object($objTemplates) && ($objTemplates->count() == 1 || $strCommand == CMD_EDIT)) { if (!$blnIsFolder) { //*** Fields tab. $objTpl->setCurrentBlock("field-title"); $objTpl->setVariable("HEADER", $objLang->get("fields", "label")); $objTpl->parseCurrentBlock(); $objTpl->setCurrentBlock("description-fields"); $objTpl->setVariable("LABEL", $objLang->get("requiredFields", "form")); $objTpl->parseCurrentBlock(); //*** Set all language as active by default for a new element if ($strCommand == CMD_ADD) { $objContentLangs = ContentLanguage::select(); $aActiveLanguages = array(); foreach ($objContentLangs as $objContentLang) { $aActiveLanguages[] = $objContentLang->getId(); } $objTpl->setVariable("ACTIVES_LANGUAGE", implode(",", $aActiveLanguages)); } } //*** Permissions tab. // $objTpl->setCurrentBlock("permission-title"); // $objTpl->setVariable("HEADER", $objLang->get("permissions", "label")); // $objTpl->parseCurrentBlock(); // $objTpl->setCurrentBlock("description-permission"); // $objTpl->setVariable("LABEL", $objLang->get("permissionInfo", "form")); // $objTpl->parseCurrentBlock(); } //*** Publish tab. $objTpl->setCurrentBlock("publish-title"); $objTpl->setVariable("HEADER", $objLang->get("publish", "label")); $objTpl->parseCurrentBlock(); $objTpl->setCurrentBlock("description-publish"); $objTpl->setVariable("LABEL", $objLang->get("publishInfo", "form")); $objTpl->parseCurrentBlock(); //*** Publish specific labels $objTpl->setVariable("LABEL_START_DATE", $objLang->get("startDate", "label")); $objTpl->setVariable("LABEL_END_DATE", $objLang->get("endDate", "label")); $objTpl->setVariable("LABEL_DATE", $objLang->get("date", "label")); $objTpl->setVariable("LABEL_TIME", $objLang->get("time", "label")); foreach (range(0, 23) as $hour) { $objTpl->setCurrentBlock("date.start.hour"); $objTpl->setVariable("VALUE", $hour); $objTpl->setVariable("LABEL", str_pad($hour, 2, 0, STR_PAD_LEFT)); if (trim($intStartHour) == $hour) { $objTpl->setVariable("SELECTED", "selected=\"selected\""); } $objTpl->parseCurrentBlock(); } foreach (range(0, 45, 15) as $minute) { $objTpl->setCurrentBlock("date.start.minute"); $objTpl->setVariable("VALUE", $minute); $objTpl->setVariable("LABEL", str_pad($minute, 2, 0, STR_PAD_LEFT)); if (trim($intStartMinute) == $minute) { $objTpl->setVariable("SELECTED", "selected=\"selected\""); } $objTpl->parseCurrentBlock(); } foreach (range(0, 23) as $hour) { $objTpl->setCurrentBlock("date.end.hour"); $objTpl->setVariable("VALUE", $hour); $objTpl->setVariable("LABEL", str_pad($hour, 2, 0, STR_PAD_LEFT)); if (trim($intEndHour) == $hour) { $objTpl->setVariable("SELECTED", "selected=\"selected\""); } $objTpl->parseCurrentBlock(); } foreach (range(0, 45, 15) as $minute) { $objTpl->setCurrentBlock("date.end.minute"); $objTpl->setVariable("VALUE", $minute); $objTpl->setVariable("LABEL", str_pad($minute, 2, 0, STR_PAD_LEFT)); if (trim($intEndMinute) == $minute) { $objTpl->setVariable("SELECTED", "selected=\"selected\""); } $objTpl->parseCurrentBlock(); } $objTpl->setVariable("LANG", strtolower($objLang->get("abbr"))); //*** Render the element form. $objTpl->setVariable("BUTTON_CANCEL", $objLang->get("back", "button")); $objTpl->setVariable("BUTTON_FORMCANCEL", $objLang->get("cancel", "button")); $objTpl->setVariable("CID", NAV_PCMS_ELEMENTS); $objTpl->setVariable("CMD", $strCommand); $objTpl->setVariable("EID", $intElmntId); break; case CMD_EXPORT_ELEMENT: $objTpl->loadTemplatefile("export.tpl.htm"); $arrElementIds = NULL; // export via selection of (multiple) elements if (isset($_GET['sel'])) { $arrElementIds = explode(',', $intElmntId); $objChild = Element::selectByPK($arrElementIds[0]); $objElement = Element::selectByPK($objChild->getParentId()); } else { $objElement = Element::selectByPK($intElmntId); } //*** Set section title. $objTpl->setVariable("MAINTITLE", $objLang->get("export", "label")); //*** Set tab title. $objTpl->setCurrentBlock("headertitel_simple"); $objTpl->setVariable("HEADER_TITLE", $objLang->get("exportOptions", "label")); $objTpl->parseCurrentBlock(); $objTpl->setVariable("FORM_NAME", "exportForm"); //*** Handle request & create export if ($_SERVER['REQUEST_METHOD'] == 'POST') { $arrElementFilters = array(); $arrTemplateFilters = array(); foreach ($_POST['elem'] as $id => $val) { $arrElementFilters[] = intval($id); $objTmpElement = Element::selectByPK(intval($id)); if (!in_array($objTmpElement->getTemplateId(), $arrTemplateFilters)) { $arrTemplateFilters[] = $objTmpElement->getTemplateId(); } } if ($_POST['sel'] == 1) { $includeSelf = false; $arrElementIds = explode(',', $intElmntId); $objChild = Element::selectByPK($arrElementIds[0]); $objElement = Element::selectByPK($objChild->getParentId()); } else { $includeSelf = true; $objElement = Element::selectByPK($intElmntId); } $strZipFile = ImpEx::exportFrom($objElement->getId(), $objElement->getTemplateId(), $arrElementFilters, $arrTemplateFilters, $_CONF['app']['account']->getId(), true, true, $includeSelf); //*** Return XML. header("HTTP/1.1 200 OK"); header("Pragma: public"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); header('Content-Type: application/octetstream; charset=utf-8'); header("Content-Length: " . (string) filesize($strZipFile)); header('Content-Disposition: attachment; filename="' . date("Y-m-d") . '_exportElements.zip"'); header("Content-Transfer-Encoding: binary\n"); readfile($strZipFile); unlink($strZipFile); exit; } //*** Create element checkboxes $objTpl->setVariable("SELECT_ITEMS", $objLang->get("selectElements", "label")); $objTpl->setVariable("FORM_CHECKBOXES", createElementTree($objElement, isset($_GET['sel']), $arrElementIds)); //*** Set form buttons $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}&cmd=" . CMD_LIST); $objTpl->setCurrentBlock("singleview"); $objTpl->setVariable("BUTTON_CANCEL", $objLang->get("back", "button")); $objTpl->setVariable("BUTTON_FORMCANCEL", $objLang->get("cancel", "button")); $objTpl->setVariable("LABEL_SAVE", $objLang->get("export", "button")); $objTpl->setVariable("CID", NAV_PCMS_ELEMENTS); $objTpl->setVariable("CMD", CMD_EXPORT_ELEMENT); $objTpl->setVariable("EID", $intElmntId); $objTpl->setVariable("SEL", isset($_GET['sel']) ? '1' : '0'); $objTpl->parseCurrentBlock(); break; case CMD_IMPORT_ELEMENT: $objTpl->loadTemplatefile("import.tpl.htm"); //*** Parse the template. $objElement = Element::selectByPK($intElmntId); //*** Set section title. $objTpl->setVariable("MAINTITLE", $objLang->get("import", "label")); //*** Set tab title. $objTpl->setCurrentBlock("headertitel_simple"); $objTpl->setVariable("HEADER_TITLE", $objLang->get("importOptions", "label")); $objTpl->parseCurrentBlock(); //*** Handle request & do import if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_FILES["file"]["name"])) { if ($_FILES["file"]["error"] > 0) { $objTpl->setVariable('ERROR_MAIN', 'Error: ' . $_FILES["file"]["error"]); } else { if (end(explode(".", $_FILES["file"]["name"])) !== 'zip') { $objTpl->setVariable('ERROR_MAIN', 'Error: Only *.ZIP files allowed'); } else { if (!ImpEx::importIn($_FILES["file"]["tmp_name"], $objElement->getId(), $objElement->getTemplateId(), $_CONF['app']['account']->getId(), false, true, true)) { $objTpl->setVariable('ERROR_MAIN', 'Templates and/or fields of templates in file do not match the destination templates'); } } } } $objTpl->setVariable('CUR_LOCATION', $objElement->getName()); $objTpl->setVariable("IMPORT_FILE", $objLang->get("importFile", "label")); $objTpl->setVariable("IMPORT_FILE_TIP", $objLang->get("importFile", "tip")); //*** Set form buttons $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}&cmd=" . CMD_LIST); $objTpl->setCurrentBlock("singleview"); $objTpl->setVariable("BUTTON_CANCEL", $objLang->get("back", "button")); $objTpl->setVariable("BUTTON_FORMCANCEL", $objLang->get("cancel", "button")); $objTpl->setVariable("LABEL_SAVE", $objLang->get("import", "button")); $objTpl->setVariable("CID", NAV_PCMS_ELEMENTS); $objTpl->setVariable("CMD", CMD_IMPORT_ELEMENT); $objTpl->setVariable("EID", $intElmntId); $objTpl->parseCurrentBlock(); break; } return $objTpl->get(); }
private function revert($facturas) { $ftpConnection = \FTP::connection(); foreach ($facturas as $factura) { $numFac = $factura["num_factura"]; $ejercicio = $factura["ejercicio"]; $pdfName = $factura["file_pdf"]; FacturasWeb::where("num_factura", $numFac)->where("ejercicio", $ejercicio)->delete(); $ftpConnection->delete("clientes.logival.es/facturas/{$pdfName}"); } \FTP::disconnect(); }