/**
  * Returns the content formatted to be correctly displayed in the editor mode.
  *   
  * @return string
  *
  */
 public function getDisplayContentForEditorMode()
 {
     $content = $this->content->getContent();
     $width = w3sCommonFunctions::getTagAttribute($content, 'width');
     $height = w3sCommonFunctions::getTagAttribute($content, 'height');
     return sprintf('<div style="width:%spx;height:%spx;background-image:url(%s);background-position:center center;background-repeat:no-repeat;border:1px dotted #D90000;"></div>', $width, $height, sfConfig::get('app_w3s_web_skin_images_dir') . '/structural/w3s_flash.png');
 }
 /**
  * Overrides the standard w3sTemplateEngine constructor to render only the
  * a template without contents.
  * 
  * @param The id of the template to render
  * 
  */
 public function __construct($idTemplate, $otherTemplate)
 {
     $this->idTemplate = $idTemplate;
     $template = DbFinder::from('W3sTemplate')->with('W3sProject')->findPK($idTemplate);
     if ($template != null) {
         $this->otherTemplate = $otherTemplate;
         // Finds the current template for slot mapper, if exists
         $currentTemplate = sprintf('[%s][%s]', $idTemplate, $otherTemplate);
         $slots = DbFinder::from('W3sSlotMapper')->where('Templates', $currentTemplate)->count();
         // Current template doesn't exist
         if ($slots == 0) {
             // Checks for corrispondence, tring to invert destination with source
             $currentTemplate = sprintf('[%s][%s]', $otherTemplate, $idTemplate);
             $slots = DbFinder::from('W3sSlotMapper')->where('Templates', $currentTemplate)->count();
             if ($slots > 0) {
                 $this->currentTemplate = $currentTemplate;
             }
         } else {
             $this->currentTemplate = sprintf('[%s][%s]', $idTemplate, $otherTemplate);
         }
         $this->templateName = $template->getTemplateName();
         $this->projectName = $template->getW3sProject()->getProjectName();
         $this->pageContents = w3sCommonFunctions::readFileContents(self::getTemplateFile($this->projectName, $this->templateName));
     } else {
         $this->templateName = null;
         $this->projectName = null;
         $this->pageContents = w3sCommonFunctions::toI18n('The requested template has not been found in the database and cannot be rendered.');
     }
 }
예제 #3
0
 /**
  * Executes ResizeImage action
  *
  * This action can be used into an ajax action to resize an image. This function requires
  * some parameters:
  *  image         : The name of the image to resize
  *  imagePath     : The full image path
  *  imageWidth    : The new image width
  *  imageHeight   : The new image height
  *  imageType     : The new image type. This parameter must be 1-GIF 2-JPG 3-PNG. Other
  *                  formats will be ignored
  *  imageQuality  : The new value for the image quality. Applies only to JPG images
  *
  *  return A JSon header.
  */
 public function executeResizeImage()
 {
     // Resizes the image
     $imagePath = w3sCommonFunctions::checkLastDirSeparator(sfConfig::get('app_images_path'));
     $imageEditor = new ImageEditor($this->getRequestParameter('image'), $imagePath);
     echo $this->getRequestParameter('imageWidth') . ' - ' . $this->getRequestParameter('imageHeight');
     $imageEditor->resize($this->getRequestParameter('imageWidth'), $this->getRequestParameter('imageHeight'));
     // Retrieve the image type and verifies if the new image will be of the same type
     $imageAttributes = getimagesize($imagePath . $this->getRequestParameter('image'));
     $newType = $this->getRequestParameter('imageType') != $imageAttributes[2] ? $this->getRequestParameter('imageType') : 0;
     // Writes the new image and returns its name
     $newFileName = $imageEditor->outputFile($this->getRequestParameter('image'), $imagePath, $newType, $this->getRequestParameter('imageQuality'));
     // Produces the output header for ajax calling.
     $canvasImage = w3sClassImageManager::getImageAttributes($newFileName, $this->getRequestParameter('previewWidth'), $this->getRequestParameter('previewHeight'), $this->getRequestParameter('setCanvas'));
     //$output = '[["w3s_image_size", "' . $imageAttributes["size"] . '"],["w3s_image_preview", "' . $imageAttributes["htmlImage"] . '"], ["w3s_image_canvas", "' . $imageAttributes["canvasValue"] . '"],["w3s_start_width", "' . $imageAttributes["width"] . '"],["w3s_start_height", "' . $imageAttributes["height"] . '"]]';
     $jsonImage = '[["w3s_image_preview", "' . $canvasImage["htmlImage"] . '"],';
     $jsonImage .= '["w3s_editor_image_size", "' . $canvasImage["size"] . '"],';
     $jsonImage .= '["w3s_editor_width", "' . $canvasImage["width"] . '"],';
     $jsonImage .= '["w3s_editor_height", "' . $canvasImage["height"] . '"],';
     $jsonImage .= '["w3s_editor_type_select", "' . $canvasImage["imageType"] . '"],';
     $jsonImage .= '["w3s_editor_canvas", "' . $canvasImage["canvasValue"] . '"],';
     $jsonImage .= '["w3s_editor_start_width", "' . $canvasImage["width"] . '"],';
     $jsonImage .= '["w3s_editor_start_height", "' . $canvasImage["height"] . '"],';
     $jsonImage .= '["w3s_ppt_htmlImage", "' . $canvasImage["htmlImage"] . '"],';
     $jsonImage .= '["w3s_ppt_imageType", "' . $canvasImage["imageType"] . '"],';
     $jsonImage .= '["w3s_ppt_size", "' . $canvasImage["size"] . '"],';
     $jsonImage .= '["w3s_ppt_width", "' . $canvasImage["width"] . '"],';
     $jsonImage .= '["w3s_ppt_height", "' . $canvasImage["height"] . '"]]';
     $this->imagesList = w3sCommonFunctions::buildFilesList($imagePath, $newFileName, array('gif', 'jpg', 'jpeg', 'png'));
     /*
         if ($newFileName != $this->getRequestParameter('image')){
         }*/
     $this->getResponse()->setHttpHeader("X-JSON", '(' . $jsonImage . ')');
     return sfView::HEADER_ONLY;
 }
 /**
  * Show the images for the menu builder editor
  */
 public function executeShowImages()
 {
     try {
         $imagesList = w3sCommonFunctions::buildFilesList(sfConfig::get('app_images_path'), '', array('gif', 'jpg', 'jpeg', 'png'));
         $imageList = new w3sImageListMenuBuilder($imagesList, $this->getRequestParameter('property'));
         return $this->renderText($imageList->renderImageList(), $this->getRequestParameter('property'));
     } catch (Exception $e) {
         return $this->renderText('Something was wrong while refreshing images lists.');
     }
 }
 /**
  * Saves the metatags for the current page
  *
  */
 public function executeLoadMetas($request)
 {
     if ($request->hasParameter('lang') && $request->hasParameter('page')) {
         if ($this->getRequestParameter('lang') != 0 && $this->getRequestParameter('page') != 0) {
             $metatag = W3sSearchEnginePeer::getFromPageAndLanguage($this->getRequestParameter('lang'), $this->getRequestParameter('page'));
             $metatagManager = new w3sMetatagsManager($metatag);
             return $this->renderPartial('metatagsInterface', array('metatagManager' => $metatagManager));
         } else {
             $this->getResponse()->setStatusCode(404);
             return $this->renderText(w3sCommonFunctions::toI18n('A required parameter has not a valid value.'));
         }
     } else {
         $this->getResponse()->setStatusCode(404);
         return $this->renderText(w3sCommonFunctions::toI18n('A required parameter misses'));
     }
 }
 public function executeExtract($request)
 {
     if ($handle = opendir(sfConfig::get('app_w3s_web_themes_dir'))) {
         while (false !== ($file = readdir($handle))) {
             $currentFile = sfConfig::get('app_w3s_web_themes_dir') . DIRECTORY_SEPARATOR . $file;
             if (is_file($currentFile)) {
                 $fileInfo = pathinfo($currentFile);
                 if ($fileInfo['extension'] == 'zip') {
                     if (w3sCommonFunctions::extractZipFile($currentFile, sfConfig::get('app_w3s_web_themes_dir'))) {
                         unlink($currentFile);
                     }
                 }
             }
         }
     }
     closedir($handle);
     return $this->renderPartial('refresh');
 }
 /** 
  * Publish all the website's pages
  */
 public function publish()
 {
     if ($this->updateDb()) {
         // Deletes the old directory with the previous published version
         w3sCommonFunctions::clearDirectory(sfConfig::get('app_w3s_web_published_dir'), array('.svn'));
         // Retrieves all the website's languages and pages from the database
         $languages = DbFinder::from('W3sLanguage')->find();
         $pages = DbFinder::from('W3sPage')->with('W3sTemplate', 'W3sProject')->leftJoin('W3sGroup')->leftJoin('W3sTemplate')->leftJoin('W3sProject')->find();
         // Cycles all the website's languages
         foreach ($languages as $language) {
             // Creates the directory for the lanugage if doesn't exists
             if (!is_dir(sfConfig::get('app_w3s_web_published_dir') . '/' . $language->getLanguage())) {
                 mkdir(sfConfig::get('app_w3s_web_published_dir') . '/' . $language->getLanguage());
             }
             // Cycles all the website's pages
             foreach ($pages as $page) {
                 // Retrieves the information needed to publish every single page
                 $pageContents = '';
                 $templateInfo = self::retrieveTemplateAttributesFromPage($page);
                 $pageContents = w3sCommonFunctions::readFileContents(self::getTemplateFile($templateInfo["projectName"], $templateInfo["templateName"]));
                 $this->idTemplate = $templateInfo["idTemplate"];
                 // Renders ther page
                 $slotContents = $this->getSlotContents($language->getId(), $page->getId());
                 foreach ($slotContents as $slot) {
                     $contents = $this->drawSlot($slot);
                     $pageContents = preg_replace('/\\<\\?php.*?include_slot\\(\'' . $slot['slotName'] . '\'\\).*?\\?\\>/', $contents, $pageContents);
                     /*$pageContents = str_replace('<?php include_slot(\'' . $slot['slotName'] . '\')?>', $contents, $pageContents);*/
                 }
                 // Renders the W3StudioCMS Copyright button. Please do not remove. See the function
                 // declaration to learn the best way to implement it in your web site.
                 // Thank you
                 $pageContents = $this->renderCopyright($pageContents);
                 // Writes the page
                 $handle = fopen(sfConfig::get('app_w3s_web_published_dir') . '/' . $language->getLanguage() . '/' . $page->getPageName() . '.php', "w");
                 fwrite($handle, $pageContents);
                 fclose($handle);
             }
         }
     } else {
         return 0;
     }
     return 1;
 }
 /**
  * Overrides the standard function
  * 
  * @return string  The rendered page 
  *
  */
 public function renderPage()
 {
     $slotNames = '';
     if ($this->idLanguage != -1 && $this->idPage != -1) {
         $slotContents = $this->getSlotContents($this->idLanguage, $this->idPage);
         foreach ($slotContents as $slot) {
             $slotNames .= sprintf('"%s",', $slot['slotName']);
             $contents = $this->drawSlot($slot);
             $this->pageContents = preg_replace('/\\<\\?php.*?include_slot\\(\'' . $slot['slotName'] . '\'\\).*?\\?\\>/', $contents, $this->pageContents);
         }
         $this->setSortables($slotContents);
     } else {
         $this->pageContents = w3sCommonFunctions::displayMessage('The page or the language requested does not exist anymore in the website');
     }
     // Renders the W3StudioCMS Copyright button. Please do not remove, neither when
     // you override this function. See the function to learn the best way to implement
     // it in your web site. Thank you.
     $this->pageContents = $this->renderCopyright($this->pageContents);
     return $this->pageContents;
 }
 public function executeEdit(sfWebRequest $request)
 {
     if ($request->hasParameter('idGroup') && ($request->hasParameter('groupName') || $request->hasParameter('idTemplate'))) {
         $group = DbFinder::from('W3sGroup')->findPK($this->getRequestParameter('idGroup'));
         if ($group != null) {
             $groupManager = new w3sGroupManager($group);
             $result = $groupManager->edit($request->getParameter('groupName'), $request->getParameter('idTemplate'));
         } else {
             $result = 2;
         }
         $groupEditor = null;
         if ($result != 1) {
             $this->getResponse()->setStatusCode(404);
             $groupEditor = new w3sGroupEditorForEdit($request->getParameter('idGroup'), $request->getParameter('groupName'));
         }
         return $this->renderPartial('edit', array('result' => $result, "groupEditor" => $groupEditor));
     } else {
         $this->getResponse()->setStatusCode(404);
         return $this->renderText(w3sCommonFunctions::toI18n('A required parameter misses.'));
     }
 }
예제 #10
0
<?php

/*
 * This file is part of the w3studioCMS package library and it is distributed 
 * under the LGPL LICENSE Version 2.1. To use this library you must leave 
 * intact this copyright notice.
 *  
 * (c) 2007-2008 Giansimon Diblas <*****@*****.**>
 *  
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * For extra documentation and help please visit http://www.w3studiocms.com
 */
use_helper('I18N');
// Result messages
$type = 'error';
switch ($result) {
    case 0:
        $message = __('An error occoured while deleting record.');
        break;
    case 1:
        $type = 'success_14';
        $message = __('The group has been succesfully deleted!');
        break;
    case 2:
        $message = __('WARNING: A serious error occoured. A required parameter misses. The group cannot be deleted.');
        break;
}
echo w3sCommonFunctions::displayMessage($message, $type, false);
 /**
  * Sets the value of the imagesPath variable.
  * 
  * @param string
  *
  */
 public function setImagesPath($value)
 {
     $this->imagesPath = w3sCommonFunctions::checkLastDirSeparator($value);
 }
 /**
  * Retrieves all the site's pages.
  * 
  * @return array An array where the key is the page's id and the value is the page's name 
  *
  */
 protected function getSitePages()
 {
     $oPages = DbFinder::from('W3sPage')->where('ToDelete', 0)->orderBy('PageName')->find();
     $pages = array('0' => 'Not linked');
     foreach ($oPages as $page) {
         $pages[$page->getId()] = w3sCommonFunctions::setStringMaxWidth($page->getPageName(), 20);
     }
     return $pages;
 }
 /**
  * Removes the stylesheets reference from the template
  * 
  * @param array    The template's stylesheets
  * @param string   The contents to process
  * 
  * @return array   The processed contents
  *
  */
 public function retrieveTemplateStylesheets($contents = null)
 {
     $result = array();
     $stylesheets = $this->getStylesheetsFromContents($contents);
     // Returns the stylesheets
     $stylesheetResults = array();
     foreach ($stylesheets[0] as $stylesheet) {
         $stylesheetsAttributes = w3sCommonFunctions::getHtmlAttributes($stylesheet, 'link');
         $stylesheetResults[] = array('href' => $stylesheetsAttributes['href'], 'media' => $stylesheetsAttributes['media']);
     }
     $result = $stylesheetResults;
     return $result;
 }
 /**
  * Renders the editor
  * 
  * @return string
  *
  */
 public function render()
 {
     $options = DbFinder::from('W3sTemplate')->find();
     return sprintf($this->editorSkeleton, label_for('group_name', w3sCommonFunctions::toI18n('Group name:')), input_tag('w3s_group_name', ''), label_for('template_name', w3sCommonFunctions::toI18n('Template name:')), select_tag('w3s_templates_select', objects_for_select($options, 'getId', 'getTemplateName')), link_to_function(w3sCommonFunctions::toI18n('Add Group'), 'W3sGroup.add()', 'id="w3s_change_button" class="link_button"'));
 }
 /**
  * Adds a new language to w3studioCMS
  * 
  * @param  array An array with the following options:
  * 								languageName - The new language's name
  * 								isMain - 1 to set the new language as main language
  * 
  * @return int - The result of the add operation
  *  
  */
 public function add($params)
 {
     if (is_array($params)) {
         if ($diff = array_diff_key(array('languageName' => ''), $params)) {
             throw new InvalidArgumentException(sprintf('%s requires the following options: \'%s\'.', get_class($this), implode('\', \'', $diff)));
         }
         try {
             $con = Propel::getConnection();
             // We assure that all the operations W3StudioCMS makes will be successfully done
             $bRollBack = false;
             $con = w3sPropelWorkaround::beginTransaction($con);
             // Retrieves the site's main language
             $mainLanguage = W3sLanguagePeer::getMainLanguage();
             // Resets the column mainLanguage is the new one will be the main language
             if ($params["isMain"] == 1) {
                 $bRollBack = !$this->resetMain($mainLanguage);
             }
             if (!$bRollBack) {
                 // Saves the language
                 $languageName = w3sCommonFunctions::slugify($params["languageName"]);
                 $this->language->setLanguage($languageName);
                 $this->language->setMainLanguage($params["isMain"]);
                 $result = $this->language->save();
                 if ($this->language->isModified() && $result == 0) {
                     $bRollBack = true;
                 } else {
                     // Copies the contents from the main language to the new one
                     $contents = $this->getReleatedContents($mainLanguage);
                     foreach ($contents as $content) {
                         $params = array("LanguageId" => $this->language->getId(), "PageId" => $content->getPageId(), "GroupId" => $content->getGroupId(), "SlotId" => $content->getSlotId(), "ContentTypeId" => $content->getContentTypeId(), "Content" => $content->getContent(), "ContentPosition" => $content->getContentPosition(), "Edited" => '1');
                         $contentManager = w3sContentManagerFactory::create($content->getContentTypeId(), $content);
                         $contentManager->setUpdateForeigns(false);
                         $result = $contentManager->add($params);
                         if ($result == 1) {
                             if (!w3sContentManagerMenuPeer::copyRelatedElements($content->getId(), $contentManager->getContent()->getId())) {
                                 $bRollBack = true;
                                 break;
                             }
                         } else {
                             $bRollBack = true;
                             break;
                         }
                     }
                 }
             }
             if (!$bRollBack) {
                 // Everything was fine so W3StudioCMS commits to database
                 $con->commit();
                 $result = 1;
             } else {
                 // Something was wrong so W3StudioCMS aborts the operation and restores to previous status
                 w3sPropelWorkaround::rollBack($con);
                 $result = 0;
             }
         } catch (Exception $e) {
             $result = 0;
             w3sPropelWorkaround::rollBack($con);
             sfContext::getInstance()->getLogger()->info("W3StudioCMS - An Error occoured while addin a language. The exception message is:\n" . $e->getMessage() . "\n");
         }
     } else {
         $result = 0;
         throw new InvalidArgumentException('Add needs an array as parameter with the required option languageName');
     }
     return $result;
 }
 protected function renderCaption($imageName)
 {
     return sprintf('%s<br />%s%sx%s<br />%s', w3sCommonFunctions::setStringMaxWidth($imageName, 15), sfContext::getInstance()->getI18N()->__('Dim:'), $this->attributes["realWidth"], $this->attributes["realHeight"], sfContext::getInstance()->getI18N()->__('Size:') . $this->attributes["size"]);
 }
예제 #17
0
 * file that was distributed with this source code.
 *
 * For extra documentation and help please visit http://www.w3studiocms.com
 */
use_helper('I18N', 'Javascript');
$i = 0;
$drags = '';
echo '<ul>';
foreach ($pagesList as $page) {
    $idPage = $page->getId();
    $class = $i / 2 == intval($i / 2) ? "w3s_white_row" : "w3s_yellow_row";
    ?>
    <li id="w3s_page_<?php 
    echo $idPage;
    ?>
" class="<?php 
    echo $class;
    ?>
"><?php 
    echo w3sCommonFunctions::setStringMaxWidth($page->getPageName(), 25);
    ?>
</li>
<?php 
    $drags .= 'new Draggable(\'w3s_page_' . $idPage . '\', {revert:1});';
    $i++;
}
echo '</ul>';
echo javascript_tag($drags);
?>

예제 #18
0
 /**
  * Draws the panel that contains the current section used. Renders the deafult
  * section, that is the fileManager
  *
  * @return string The drawed panel
  *
  */
 protected function drawContentsTabs()
 {
     $tabs = w3sCommonFunctions::loadScript('cpTabs.yml');
     $result = '';
     foreach ($tabs as $key => $tab) {
         $content = '';
         if ($key == 1) {
             $fileManager = new w3sFileManager($this->currentUser, $this->idLanguage, $this->currentPage);
             $content = $fileManager->render();
         }
         $result .= sprintf('<div id="w3s_tab_%s" class="w3s_tabs">%s</div>', $key, $content);
     }
     return $result;
 }
예제 #19
0
 * For extra documentation and help please visit http://www.w3studiocms.com
 */
use_helper('I18N', 'Object', 'Javascript');
// If something failed W3StudioCMS shows the add/edit module again
if ($result != 1) {
    $pageEditor = new w3sPageEditor();
    echo $pageEditor->render();
}
// Result messages
switch ($result) {
    case 0:
        $message = __('An error occoured during the save operation. Page not added.');
        break;
    case 1:
        $message = __('Page added succesfully!<br />Loading pages, please wait.');
        break;
    case 2:
        $message = __('This page already exists in the web site: use another name.');
        break;
    case 4:
        $message = __('You must provide a name for the new page.');
        break;
    case 8:
        $message = __('The new page you are inserting cannot be assigned to group provided because it doesn\'t exist anymore');
        break;
    case 16:
        $message = __('The new page you are inserting cannot be assigned to group provided because it has been removed from w3studioCMS');
        break;
}
echo w3sCommonFunctions::displayMessage($message, 'error', false);
예제 #20
0
 /**
  * Adds a new group
  *
  * @param  string The new group's name
  * @param  string The template's id which must be assigned the new group
  *
  * @return     int 0 - The save operation failed
  *                 1 - Success
  */
 public function edit($groupName, $idTemplate)
 {
     $groupName = w3sCommonFunctions::slugify($groupName);
     if ($groupName != 'n-a' || $idTemplate != null) {
         if ($groupName != 'n-a' && $groupName != $this->group->getGroupName() || $idTemplate != null && $this->group->getTemplateId() != $idTemplate) {
             if ($idTemplate == null || DbFinder::from('W3sTemplate')->findPK($idTemplate) != null) {
                 if ($idTemplate != null) {
                     $this->group->setTemplateId($idTemplate);
                 }
                 $this->group->setGroupName($groupName);
                 $this->group->setEdited(1);
                 $result = $this->group->save();
             } else {
                 // The template doesn't exist
                 $result = 16;
             }
         } else {
             // Nothing to edit
             $result = 2;
         }
     } else {
         // Group name is empty && idTemplate misses
         $result = 4;
     }
     return $result;
 }
예제 #21
0
 protected function drawPagesManager()
 {
     $commands = w3sCommonFunctions::renderCommandsFromYml('cpPagesManager.yml', $this->currentUser);
     return sprintf($this->pagesManager, $commands[0], __('Group'), $this->renderGroupsSelect(), $commands[1], $commands[2], $commands[3]);
 }
 /**
  * Renames the page
  */
 public function executeRename($request)
 {
     if ($request->hasParameter('idPage') && $request->hasParameter('newName')) {
         $page = W3sPagePeer::retrieveByPk($this->getRequestParameter('idPage'));
         if ($page != null) {
             $page->setPageName($this->getRequestParameter('newName'));
             $page->save();
             $fileManager = new w3sFileManager($this->getRequestParameter('curLang'), $this->getRequestParameter('curPage'));
             return $this->renderPartial('listPages', array('fileManager' => $fileManager));
         } else {
             $this->getResponse()->setStatusCode(404);
             return $this->renderText(w3sCommonFunctions::toI18n('The requested page does not exists anymore.'));
         }
     } else {
         $this->getResponse()->setStatusCode(404);
         return $this->renderText(w3sCommonFunctions::toI18n('One or more required parameter are missing.'));
     }
 }
예제 #23
0
 public function executeDisplayImageDir()
 {
     $this->imagesList = w3sCommonFunctions::buildFilesList(sfConfig::get('app_images_path'), '', array('gif', 'jpg', 'jpeg', 'png'));
 }
예제 #24
0
 /**
  * Sets the image and its attributes from an html image
  * 
  * @param str The html image 
  *
  */
 protected function setImageAttributes()
 {
     $imageAttributes = getimagesize($this->attributes["fullImagePath"]);
     if (!is_array($imageAttributes)) {
         throw new RuntimeException(sprintf('%s isn\'t a valid image file.', basename($this->attributes["fullImagePath"])));
     }
     $this->attributes["realWidth"] = $imageAttributes[0];
     $this->attributes["realHeight"] = $imageAttributes[1];
     $this->attributes["imageType"] = $imageAttributes[2];
     $this->attributes["width"] = $this->attributes["realWidth"];
     $this->attributes["height"] = $this->attributes["realHeight"];
     $this->attributes["size"] = w3sCommonFunctions::formatFileSize($this->attributes["fullImagePath"]);
 }
 /**
  * Generates an array similar to the one generated by the 
  * getParameterHolder()->getAll() function. It needs a serialized string
  * similar to [Parameter Name][]=[Property name]=[Property value]&;
  *
  * @param      string serialized string which must match the following rule: 
  * 						 [Parameter Name A][]=[Property name]=[Property value]&[Parameter Name A][]=[Property name]=[Property value]&[Parameter Name B][]=[Property name]=[Property value]&...
  * 
  * @return     array The array with contents formatted.
  */
 protected function saveParams($params)
 {
     $params = w3sCommonFunctions::checkLastDirSeparator($params, '&');
     preg_match_all('/([0-9]+)\\[\\]=(.*?)&/', $params, $res);
     $current = array();
     $result = array();
     $currentKey = 0;
     foreach ($res[1] as $key => $value) {
         if ($value != $currentKey) {
             if ($currentKey != 0) {
                 $result[$currentKey] = $current;
             }
             $current = array();
             $currentKey = $value;
         }
         $current[] = $res[2][$key];
     }
     $result[$currentKey] = $current;
     return $result;
 }
 /**
  * Executes openEditor action
  *
  */
 public function executeOpenEditor($request)
 {
     // The parameters passed to the forwarded action are already setted in the javascript
     if ($request->hasParameter('idContent') && $this->getRequestParameter('idContent') > 0) {
         $content = W3sContentPeer::retrieveByPk($this->getRequestParameter('idContent'));
         if ($content != null) {
             $this->editor = w3sEditorFactory::create($content);
             return $this->renderPartial('showEditor');
         }
     }
     $this->getResponse()->setStatusCode(404);
     return $this->renderText(w3sCommonFunctions::toI18n('The content you are trying to edit does not exists anymore.'));
 }
예제 #27
0
<?php

/*
 * This file is part of the w3studioCMS package library and it is distributed 
 * under the LGPL LICENSE Version 2.1. To use this library you must leave 
 * intact this copyright notice.
 *  
 * (c) 2007-2008 Giansimon Diblas <*****@*****.**>
 *  
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * For extra documentation and help please visit http://www.w3studiocms.com
 */
use_helper('I18N', 'Javascript');
/**/
switch ($status) {
    case 1:
        echo $template->renderPage();
        break;
    case 2:
        $message = __('The template cannot be rendered because a required parameter misses.');
        echo w3sCommonFunctions::displayMessage($message);
        break;
    case 4:
        $message = __('Your session has been expired: you must login again.');
        echo w3sCommonFunctions::displayMessage($message);
        break;
}
예제 #28
0
 /**
  * Sets the toolbar buttons from a yml file. See the tbMenuManager.yml for a full example
  * 
  * @param array
  *
  */
 public function fromYml($fileName)
 {
     $this->toolbar = w3sCommonFunctions::loadScript($fileName);
 }
 /**
  * Draws the panel commands.
  *
  * @return string The drawed commands
  *
  */
 protected function drawCommands()
 {
     return sprintf($this->commandsSkeleton, link_to_function(w3sCommonFunctions::toI18N('Switch template'), 'W3sSlotMapper.switchDiv()'), link_to_function(w3sCommonFunctions::toI18N('Map slots'), 'W3sSlotMapper.map(' . $this->invertedMapExists . ')'), link_to_function(w3sCommonFunctions::toI18N('Save map'), 'W3sSlotMapper.save();'), link_to_function(w3sCommonFunctions::toI18N('Return to editor'), 'W3sSlotMapper.close();'));
 }
 /**
  * Executes delete image action.
  */
 public function executeRefreshImages()
 {
     try {
         $imageList = new w3sImageListVertical(w3sCommonFunctions::buildFilesList(sfConfig::get('app_images_path'), '', array('gif', 'jpg', 'jpeg', 'png')), '');
         return $this->renderText($imageList->renderImageList());
     } catch (Exception $e) {
         return $this->renderText('Something was wrong while refreshing images lists.');
     }
 }