/** * 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'); }
/** * Sets the image and its attributes from an html image * * @param str The html image * */ protected function imageFromHtml($value) { // retrieves only the image $htmlImage = trim(strip_tags($value, '<img>')); $this->image = $htmlImage; // Retrieves all attributes from the image $this->attributes = w3sCommonFunctions::stringToArray($this->image); $this->attributes["fullImagePath"] = sfConfig::get('sf_web_dir') . $this->attributes['src']; $this->attributes["linkedTo"] = w3sCommonFunctions::getTagAttribute(trim(strip_tags($value, '<a>')), 'href'); $this->setImageAttributes(); }
/** * Reads all the site's template files and extracts the stylesheets' references. * * Note: It's not possibile to use the $this->response->addStyleSheet method as * made in the webSite module, because w3studioCMS needs the title attribute to * change the stylesheets in editor mode. * * @return string The html stylesheets * */ public function retrieveSiteStylesheets() { // Gets all the project's templates from the database $templates = DbFinder::from('W3sTemplate')->leftJoin('W3sProject')->find(); $result = ''; foreach ($templates as $template) { $templateContents = w3sCommonFunctions::readFileContents(self::getTemplateFile($template->getW3sProject()->getProjectName(), $template->getTemplateName())); $stylesheets = $this->getStylesheetsFromContents($templateContents); foreach ($stylesheets[0] as $stylesheet) { // Set for every stylesheet the title that corresponds to the stylesheet's name. // This is required by the function that changes the template's stylesheet $stylesheetName = basename(w3sCommonFunctions::getTagAttribute($stylesheet, 'href')); $stylesheetName = str_replace('.css', '', $stylesheetName); $result .= str_replace('<link', sprintf('<link title="%s" ', $stylesheetName), $stylesheet) . "\n"; } } return $result; }