示例#1
0
 public function executeSaveTag()
 {
     try {
         $parameters = $this->getRequest()->getParameterHolder()->getAll();
         if ($parameters['id']) {
             $obj = Document::getDocumentInstance($parameters['id']);
             $parent = Document::getParentOf($parameters['id']);
         } else {
             $obj = new Tag();
             $parent = Document::getDocumentInstance($parameters['parent']);
         }
         foreach ($parameters as $key => $value) {
             if (!(strpos($key, 'attr') === false)) {
                 $function = 'set' . str_replace('attr', '', $key);
                 $obj->{$function}($value);
             }
         }
         if (!$parameters['attrExclusive']) {
             $obj->setExclusive(0);
         }
         $obj->save(null, $parent);
         UtilsHelper::setBackendMsg("Saved");
     } catch (Exception $e) {
         UtilsHelper::setBackendMsg("Error while saving: " . $e->getMessage(), "error");
     }
     PanelService::redirect('tag');
     exit;
 }
示例#2
0
 public function executeEditTrademark()
 {
     $this->setLayout(false);
     $this->systemsArr = array(1 => 'BPO - Bulgaria', 2 => 'OAMI - Europe', 3 => 'WIPO - world');
     $this->kindsArr = array(1 => 'Text', 2 => 'Image', 3 => 'Mixed');
     $this->statusArr = array(1 => 'Pending', 2 => 'Registered', 3 => 'Rejected');
     return PanelService::objectEdit('trademarks', 'Trademark', $this);
 }
示例#3
0
 public function executeSavePage()
 {
     try {
         PanelService::objectSave($obj, $parent);
         Urlrewrite::updateUrlRelationCache();
         //UtilsHelper::setBackendMsg("Saved");
     } catch (Exception $e) {
         UtilsHelper::setBackendMsg("Error saving Page: " . $e->getMessage(), "error");
     }
     //		exec('rm -fr '.SF_ROOT_DIR.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.'menus/*');
     //		PanelService::redirect();
     //		exit();
 }
示例#4
0
 public function executeEditListitem()
 {
     $this->setLayout(false);
     PanelService::objectEdit('lists', 'Listitem', $this);
     //		if ($user = $this->getUser()->getSubscriber())
     //		{
     //			$this->userType = $user->getType();
     //		}
     /*		if ($this->obj)
     		{
     			if ($parent = Document::getParentOf($this->obj->getId()))
     			{
     				$this->listType = $parent->getListType();
     			}
     		}*/
 }
示例#5
0
 public function executeEditUser()
 {
     $this->setLayout(false);
     $this->user = $this->getUser()->getSubscriber();
     return PanelService::objectEdit('user', 'User', $this);
 }
示例#6
0
 public function executeEditKeyword()
 {
     $this->setLayout(false);
     return PanelService::objectEdit('keywords', 'Keyword', $this);
 }
示例#7
0
 public function executeEditLabel()
 {
     $this->setLayout(false);
     $culture = sfContext::getInstance()->getUser()->getCulture();
     $id = $this->id = $this->getRequestParameter('id');
     $this->page = $this->getRequestParameter('page');
     $phpFile = sfConfig::get('sf_root_dir') . "/cache/locales.php";
     $xmlFile = sfConfig::get('sf_root_dir') . "/config/locales.xml";
     if ($this->getRequestParameter('submitEdit')) {
         $attrValue = $this->getRequestParameter('attrValue');
         if (trim($attrValue) == '') {
             $request = $this->getRequest();
             $request->setError('attrValue', 1);
             UtilsHelper::setBackendMsg('Field <b>Value</b> is empty!', 'error');
             return;
         }
         $locale = $id;
         // write XML Locales (in lib folder);
         if ($content = file_get_contents($xmlFile)) {
             $lines = explode("</locale>", $content);
             $changed = false;
             foreach ($lines as &$line) {
                 if (strpos($line, '<locale label="' . $locale . '"') != false) {
                     $arr = explode("\n", $line);
                     foreach ($arr as &$l) {
                         if (strpos($l, '<item lang="' . $culture . '"') != false) {
                             //$v = str_replace('"', "'", $attrValue);
                             //$val = htmlspecialchars($attrValue);
                             $val = htmlentities($attrValue, ENT_COMPAT | ENT_HTML401, 'UTF-8');
                             $l = '		<item lang="' . $culture . '" value="' . $val . '" />';
                             $changed = true;
                             break;
                         }
                     }
                     $line = implode("\n", $arr);
                     break;
                 }
             }
             if ($changed) {
                 $content = implode("</locale>", $lines);
                 file_put_contents($xmlFile, $content);
             } else {
                 $request = $this->getRequest();
                 $request->setError('attrValue', 1);
                 UtilsHelper::setBackendMsg('Locale "' . $id . '" is missing in XML file!', 'error');
                 return;
             }
         }
         // write COMPILED Locales (in cache folder);
         if ($content = file_get_contents($phpFile)) {
             $lines = explode("\n", $content);
             foreach ($lines as &$line) {
                 // replace ['media.frontend.gallery-no-tag-warn']['en']
                 if (strpos($line, "['{$id}']") != false) {
                     //$val = str_replace('"', '\"', $attrValue);
                     //$val = htmlspecialchars($attrValue);
                     $val = htmlentities($attrValue, ENT_COMPAT | ENT_HTML401, 'UTF-8');
                     $line = "\t\$locales['{$id}'] = \"{$val}\";";
                     break;
                 }
             }
             $content = implode("\n", $lines);
             file_put_contents($phpFile, $content);
         }
         PanelService::redirect();
     } else {
         if (!($this->val = $this->getRequestParameter('attrValue'))) {
             include $phpFile;
             $this->val = htmlspecialchars_decode($locales[$id]);
         }
         $this->id = $id;
     }
 }
示例#8
0
 public function executeEditClient()
 {
     $this->setLayout(false);
     return PanelService::objectEdit('clients', 'Client', $this);
 }
示例#9
0
 public function executeEditNews()
 {
     $this->setLayout(false);
     return PanelService::objectEdit('news', 'News', $this);
 }
示例#10
0
 public function executeEditMailinglist()
 {
     $this->setLayout(false);
     PanelService::objectEdit('newsletter', 'Mailinglist', $this);
 }
示例#11
0
 public function executeSaveMedia()
 {
     $hasError = false;
     try {
         $request = $this->getRequest();
         $id = $this->getRequestParameter("id");
         if ($this->getRequestParameter("submitEdit")) {
             $fileName = $request->getFilePath('attrFilename');
             if (!$id && !$fileName) {
                 UtilsHelper::setBackendMsg("Error: Please upload an image (JPG, GIF or JPG)!", "error");
                 return;
             }
             if ($fileName) {
                 $allowedArr = array("image/gif", "image/png", "image/jpg", "image/jpeg", "image/pjpeg");
                 $media = Media::upload('attrFilename', 'upload', $allowedArr);
                 $media->resizeImage("thumbs", null, 100);
             }
         }
     } catch (Exception $e) {
         $hasError = true;
         UtilsHelper::setBackendMsg("Error while saving: " . $e->getMessage(), "error");
     }
     if (!$hasError) {
         PanelService::redirect();
         exit;
     }
 }
示例#12
0
 public function executeEditGallery()
 {
     $this->setLayout(false);
     return PanelService::objectEdit('galleries', 'Gallery', $this);
 }
示例#13
0
 public function executeEditSettings()
 {
     $this->setLayout(false);
     $culture = sfContext::getInstance()->getUser()->getCulture();
     $id = $this->id = $this->getRequestParameter('id');
     $this->page = $this->getRequestParameter('page');
     $phpFile = sfConfig::get('sf_root_dir') . "/cache/settings.php";
     $xmlFile = sfConfig::get('sf_root_dir') . "/config/settings.xml";
     if ($this->getRequestParameter('submitEdit')) {
         $attrValue = $this->getRequestParameter('attrValue');
         if (trim($attrValue) == '') {
             $request = $this->getRequest();
             $request->setError('attrValue', 1);
             UtilsHelper::setBackendMsg('Field <b>Value</b> is empty!', 'error');
             return;
         }
         $setting = $id;
         if ($content = file_get_contents($xmlFile)) {
             $lines = explode("</element>", $content);
             $changed = false;
             foreach ($lines as &$line) {
                 if (strpos($line, '<element label="' . $setting . '"') != false) {
                     $arr = explode("\n", $line);
                     foreach ($arr as &$l) {
                         if (strpos($l, '<item lang="' . $culture . '"') != false) {
                             $v = htmlspecialchars($attrValue);
                             $l = '		<item lang="' . $culture . '" value="' . $v . '" />';
                             $changed = true;
                             break;
                         }
                     }
                     $line = implode("\n", $arr);
                     break;
                 }
             }
             if ($changed) {
                 $content = implode("</element>", $lines);
                 file_put_contents($xmlFile, $content);
             } else {
                 $request = $this->getRequest();
                 $request->setError('attrValue', 1);
                 UtilsHelper::setBackendMsg('Settings "' . $id . '" is missing in XML file!', 'error');
                 return;
             }
         }
         if ($content = file_get_contents($phpFile)) {
             $lines = explode("\n", $content);
             foreach ($lines as &$line) {
                 if (strpos($line, "['{$id}']") != false) {
                     $v = str_replace('"', '\\"', $attrValue);
                     $line = "\t\$settings['{$id}'] = \"{$v}\";";
                     break;
                 }
             }
             $content = implode("\n", $lines);
             file_put_contents($phpFile, $content);
         }
         PanelService::redirect();
     } else {
         if (!($this->val = $this->getRequestParameter('attrValue'))) {
             include $phpFile;
             $this->val = htmlspecialchars_decode($settings[$id]);
         }
         $this->id = $id;
     }
 }
示例#14
0
 public function executeEditSlider()
 {
     $this->setLayout(false);
     return PanelService::objectEdit('slider', 'Slider', $this);
 }
示例#15
0
 public function executeEditSearch()
 {
     $this->setLayout(false);
     return PanelService::objectEdit('search', 'Search', $this);
 }
示例#16
0
 public static function objectSave(&$obj, &$parent, $documentName = null)
 {
     try {
         $parameters = sfContext::getInstance()->getRequest()->getParameterHolder()->getAll();
         if (!$documentName) {
             $documentName = $parameters["documentName"];
         }
         if (!$parent) {
             $parent = Document::getDocumentInstance($parameters['parent']);
         }
         if (!$parent) {
             if (isset($parameters["parentModule"])) {
                 $parent = Rootfolder::getRootfolderByModule($parameters["parentModule"]);
             } else {
                 $parent = Rootfolder::getRootfolderByModule($moduleName);
             }
         }
         if (!is_object($obj)) {
             if (is_numeric($parameters['id']) && !$parent) {
                 $obj = Document::getDocumentInstance($parameters['id']);
                 $parent = Document::getParentOf($parameters['id']);
                 $documentName = $parameters["documentName"];
             } else {
                 $obj = new $documentName();
             }
         }
         include_once sfConfig::get('sf_root_dir') . "/config/Schema.class.php";
         $m = "get" . $documentName . "Properties";
         $properties = Schema::$m();
         $contentArr = array();
         foreach ($parameters as $key => $value) {
             // parse Content attribute/s for Page
             if ($documentName == "Page" && substr($key, 0, 11) == 'attrContent' && $key > 'attrContent' && in_array('Content', $properties)) {
                 $ind = intval(substr($key, 11));
                 // check if creating NEW Page
                 if ($ind == 0) {
                     $ind = 1;
                 }
                 $contentArr[$parameters['contentID' . $ind]] = '<block id="' . $parameters['contentID' . $ind] . '" target="' . $parameters['contentTarget' . $ind] . '" action="richtext"><![CDATA[' . $value . ']]></block>';
             } else {
                 if (!(strpos($key, 'attr') === false) && $key != "attrRewriteUrl") {
                     if ($value == '') {
                         $value = null;
                     }
                     $key = str_replace('attr', '', $key);
                     if ($properties && $key != "Password" && !in_array($key, $properties)) {
                         continue;
                     }
                     if ($key == "Password" && empty($value)) {
                         continue;
                     }
                     $function = 'set' . $key;
                     if (is_array($value)) {
                         // date field
                         if (array_key_exists('year', $value) || array_key_exists('month', $value) || array_key_exists('day', $value)) {
                             //$value = implode('-', $value);
                             //							$date = $value['year'].'-'.str_pad($value['month'], 2, "0", STR_PAD_LEFT).'-'.str_pad($value['day'], 2, "0", STR_PAD_LEFT); // 2009-02-09 16:10:20
                             $date = implode('-', $value);
                             if ($value['hour'] && $value['minute']) {
                                 // if 'include_custom' is used
                                 if (empty($value['year']) || empty($value['month']) || empty($value['day']) || empty($value['hour']) || empty($value['minute'])) {
                                     $value = null;
                                 } else {
                                     $time = $value['hour'] . ':' . $value['minute'];
                                     $value = $date . ' ' . $time;
                                 }
                             } else {
                                 // if 'include_custom' is used
                                 if (empty($value['year']) && empty($value['month']) && empty($value['day'])) {
                                     $value = null;
                                 } else {
                                     $value = $date;
                                 }
                             }
                         } else {
                             $value = implode(";", $value);
                         }
                     }
                     if ($key == "Related") {
                         if ($value) {
                             $value = '[' . str_replace(';', '][', $value) . ']';
                             $value = str_replace('[]', '', $value);
                         }
                     }
                     if ($key == "Keywords") {
                         if ($value) {
                             $value = '[' . str_replace(',', '][', $value) . ']';
                             $value = str_replace('[]', '', $value);
                         }
                     }
                     $obj->{$function}($value);
                 }
             }
         }
         // Page content save
         if ($documentName == 'Page' && count($contentArr) > 0) {
             // add original NON-RICHTEXT content blocks
             $orgContent = $obj->getContent();
             $blocks = self::get_content_blocks($orgContent);
             foreach ($blocks as $name => $block) {
                 $contentArr[$name] = '<block id="' . $name . '" target="' . $block['target'] . '" action="' . $block['action'] . '"><![CDATA[' . $block['content'] . ']]></block>';
             }
             $allBlocks = PanelService::get_all_content_blocks($orgContent);
             $content = '';
             foreach ($allBlocks as $blockName => $blockData) {
                 $content .= $contentArr[$blockName];
             }
             $content = '<?xml version="1.0" encoding="UTF-8"?><blocks>' . $content . '</blocks>';
             $obj->setContent($content);
         }
         if ($documentName == "Page") {
             $obj->setRewriteUrl($parameters["attrRewriteUrl"]);
         }
         $obj->save(null, $parent);
         if ($tags = Document::getAvailableTagsOf($parameters['moduleName'], $documentName)) {
             foreach ($tags as $tag) {
                 if ($parameters['tag_id_' . $tag->getId()]) {
                     Document::addTag($obj, $tag->getTagId());
                 } else {
                     Document::removeTag($obj, $tag->getTagId());
                 }
             }
             Tagrelation::updateTagRelationCache();
         }
         //UtilsHelper::setBackendMsg("Saved");
     } catch (Exception $e) {
         throw $e;
     }
 }
示例#17
0
 public function executeEditProduct()
 {
     $this->setLayout(false);
     return PanelService::objectEdit('products', 'Product', $this);
 }