getImageId() public method

public getImageId ( ) : integer
return integer
コード例 #1
0
 /**
  * @Route("get_img", name="newscoop_get_img")
  */
 public function indexAction(Request $request)
 {
     // reads parameters from image link URI
     $imageId = $request->get('ImageId', null);
     $articleNr = $request->get('NrArticle', null);
     $imageNr = $request->get('NrImage', null);
     $imageRatio = $request->get('ImageRatio', null);
     $imageResizeWidth = $request->get('ImageWidth', null);
     $imageResizeHeight = $request->get('ImageHeight', null);
     $imageCrop = $request->get('ImageForcecrop', null);
     $resizeCrop = $request->get('ImageCrop', null);
     if (empty($imageId) && !empty($imageNr) && !empty($articleNr)) {
         $articleImage = new \ArticleImage($articleNr, null, $imageNr);
         $imageId = $articleImage->getImageId();
     }
     $showImage = new \CampGetImage($imageId, $imageRatio, $imageResizeWidth, $imageResizeHeight, $imageCrop, $resizeCrop);
     die;
 }
コード例 #2
0
ファイル: MetaSubtitle.php プロジェクト: nistormihai/Newscoop
    /**
     * Process the image statement given in Campsite internal formatting.
     * Returns a standard image URL.
     *
     * @param array $p_matches
     * @return string
     */
    public static function ProcessImageLink(array $p_matches) {
    	$context = CampTemplate::singleton()->context();
    	$oldImage = $context->image;
        $uri = $context->url;
        if ($uri->article->number == 0) {
            return '';
        }

        $imageNumber = $p_matches[1];
        $detailsString = $p_matches[2];
        $detailsArray = array();
        if (trim($detailsString) != '') {
        	$imageAttributes = 'align|alt|sub|width|height|ratio|\w+';
        	preg_match_all("/[\s]+($imageAttributes)=\"([^\"]+)\"/i", $detailsString, $detailsArray1);
        	$detailsArray1[1] = array_map('strtolower', $detailsArray1[1]);
        	if (count($detailsArray1[1]) > 0) {
        		$detailsArray1 = array_combine($detailsArray1[1], $detailsArray1[2]);
        	} else {
        		$detailsArray1 = array();
        	}
        	preg_match_all("/[\s]+($imageAttributes)=([^\"\s]+)/i", $detailsString, $detailsArray2);
        	$detailsArray2[1] = array_map('strtolower', $detailsArray2[1]);
        	if (count($detailsArray2[1]) > 0) {
        		$detailsArray2 = array_combine($detailsArray2[1], $detailsArray2[2]);
        	} else {
        		$detailsArray2 = array();
        	}
        	$detailsArray = array_merge($detailsArray1, $detailsArray2);
        }

        $articleImage = new ArticleImage($uri->article->number, null, $imageNumber);
        $imageObj = $articleImage->getImage();
        $image = new MetaImage($articleImage->getImageId());
        $context->image = $image;
        $imageSize = @getimagesize($imageObj->getImageStorageLocation());
        unset($imageObj);

        $imageOptions = '';
        $defaultOptions = array('ratio'=>'EditorImageRatio', 'width'=>'EditorImageResizeWidth',
        'height'=>'EditorImageResizeHeight');
        foreach (array('ratio', 'width', 'height') as $imageOption) {
        	$defaultOption = (int)SystemPref::Get($defaultOptions[$imageOption]);
        	if (isset($detailsArray[$imageOption]) && $detailsArray[$imageOption] > 0) {
        		$imageOptions .= " $imageOption " . (int)$detailsArray[$imageOption];
        	} elseif ($imageOption != 'ratio' && $defaultOption > 0) {
        		$imageOptions .= " $imageOption $defaultOption";
        	} elseif ($imageOption == 'ratio' && $defaultOption != 100) {
        		$imageOptions .= " $imageOption $defaultOption";
        	}
        }
        $imageOptions = trim($imageOptions);

        $imgZoomLink = '';
        if (SystemPref::Get("EditorImageZoom") == 'Y' && strlen($imageOptions) > 0) {
        	$uri->uri_parameter = "image";
            $imgZoomLink = '<a href="' . $uri->uri . '" class="photoViewer" ';
            if (isset($detailsArray['sub']) && !empty($detailsArray['sub'])) {
                $imgZoomLink .= 'title="' . $detailsArray['sub'] . '">';
            } else {
                $imgZoomLink .= 'title="">';
            }
        }

        $isCentered = false;
        $imgString = '</p><div class="cs_img"';
        if (isset($detailsArray['align']) && !empty($detailsArray['align'])) {
            if ($detailsArray['align'] == 'middle') {
                $imgString = '</p><div align="center"><div class="cs_img"';
                $isCentered = true;
            } else {
                $imgString .= ' style="float:' . $detailsArray['align'] . ';"';
            }
        }
        $imgString .= '>';
        $imgString .= (strlen($imgZoomLink) > 0) ? '<p>'.$imgZoomLink : '<p>';
        $uri->uri_parameter = "image $imageOptions";
        $imgString .= '<img src="' . $uri->uri . '"';
        if (isset($detailsArray['alt']) && !empty($detailsArray['alt'])) {
            $imgString .= ' alt="' . $detailsArray['alt'] . '"';
        }
        if (isset($detailsArray['sub']) && !empty($detailsArray['sub'])) {
            $imgString .= ' title="' . $detailsArray['sub'] . '"';
        }
        $imgString .= ' border="0"/>';
        $imgString .= (strlen($imgZoomLink) > 0) ? '</a></p>' : '</p>';
        if (isset($detailsArray['sub']) && !empty($detailsArray['sub'])) {
            $imgString .= '<p class="cs_img_caption">';
            $imgString .= $detailsArray['sub'] . '</p>';
        }
        if ($isCentered) {
            $imgString .= '</div></div><p>';
        } else {
            $imgString .= '</div><p>';
        }
        $context->image = $oldImage;

        return $imgString;
    }
コード例 #3
0
ファイル: merge3.php プロジェクト: nistormihai/Newscoop
        				$text = preg_replace("/<!\*\*\s*Title\s*>/i", "<span class=\"campsite_subhead\">", $text);
        				$text = preg_replace("/<!\*\*\s*EndTitle\s*>/i", "</span>", $text);

        				// Internal Links with targets
        				$text = preg_replace("/<!\*\*\s*Link\s*Internal\s*([\w=&]*)\s*target\s*([\w_]*)\s*>/i", '<a href="/campsite/campsite1_internal_link?$1" target="$2">', $text);
        				// Internal Links without targets
        				$text = preg_replace("/<!\*\*\s*Link\s*Internal\s*([\w=&]*)\s*>/i", '<a href="/campsite/campsite1_internal_link?$1">', $text);
        				// End link
        				$text = preg_replace("/<!\*\*\s*EndLink\s*>/i", "</a>", $text);
        				// Images
        				preg_match_all("/<!\*\*\s*Image\s*([\d]*)\s*/i",$text, $imageMatches);
        				if (isset($imageMatches[1][0])) {
        					foreach ($imageMatches[1] as $templateId) {
        						// Get the image URL
        						$articleImage = new ArticleImage($srcArticleData->getProperty('NrArticle'), null, $templateId);
        						$image = new Image($articleImage->getImageId());
        						$imageUrl = $image->getImageUrl();
        						$text = preg_replace("/<!\*\*\s*Image\s*".$templateId."\s*/i", '<img src="'.$imageUrl.'" id="'.$templateId.'" ', $text);
        					}
        				}
        			?>
        			<TR>
        			<TD ALIGN="RIGHT" VALIGN="TOP" style="padding-top: 8px; padding-right: 5px;">
        			</td>
        			<td align="right" valign="top" style="padding-top: 8px;">
        				<?php echo htmlspecialchars($dbColumn->getDisplayName()); ?>:
        			</td>
        			<TD align="left" valign="top">
        				<table cellpadding="0" cellspacing="0" width="100%">
        				<tr>
        					<td align="left" style="padding: 5px; <?php if (!empty($text)) {?>border: 1px solid #888; margin-right: 5px;<?php } ?>" <?php if (!empty($text)) {?>bgcolor="#EEEEEE"<?php } ?>><?php p($text); ?></td>
コード例 #4
0
ファイル: MetaArticle.php プロジェクト: nistormihai/Newscoop
 /**
  * Returns an image meta object corresponding to the given index
  * of the image attachment inside the article. Returns an empty
  * meta image object if the image did not exist.
  *
  * @param int $p_imageIndex - the index of the image attachment in the article
  * @return MetaImage
  */
 public function image($p_imageIndex) {
     $articleImage = new ArticleImage($this->m_dbObject->getArticleNumber(),
     null, $p_imageIndex);
     if (!$articleImage->exists()) {
         return new MetaImage();
     }
     return new MetaImage($articleImage->getImageId());
 }
コード例 #5
0
ファイル: MetaSubtitle.php プロジェクト: alvsgithub/Newscoop
 /**
  * Process the image statement given in Campsite internal formatting.
  * Returns a standard image URL.
  *
  * @param  array  $p_matches
  * @return string
  */
 public static function ProcessImageLink(array $p_matches)
 {
     $context = CampTemplate::singleton()->context();
     $oldImage = $context->image;
     $uri = $context->url;
     if ($uri->article->number == 0) {
         return '';
     }
     $imageNumber = $p_matches[1];
     $detailsString = $p_matches[2];
     $detailsArray = array();
     if (trim($detailsString) != '') {
         $imageAttributes = 'align|alt|sub|width|height|ratio|\\w+';
         preg_match_all("/[\\s]+({$imageAttributes})=\"([^\"]+)\"/i", $detailsString, $detailsArray1);
         $detailsArray1[1] = array_map('strtolower', $detailsArray1[1]);
         if (count($detailsArray1[1]) > 0) {
             $detailsArray1 = array_combine($detailsArray1[1], $detailsArray1[2]);
         } else {
             $detailsArray1 = array();
         }
         preg_match_all("/[\\s]+({$imageAttributes})=([^\"\\s]+)/i", $detailsString, $detailsArray2);
         $detailsArray2[1] = array_map('strtolower', $detailsArray2[1]);
         if (count($detailsArray2[1]) > 0) {
             $detailsArray2 = array_combine($detailsArray2[1], $detailsArray2[2]);
         } else {
             $detailsArray2 = array();
         }
         $detailsArray = array_merge($detailsArray1, $detailsArray2);
     }
     $articleImage = new ArticleImage($uri->article->number, null, $imageNumber);
     $imageObj = $articleImage->getImage();
     $image = new MetaImage($articleImage->getImageId());
     $context->image = $image;
     $imageSize = @getimagesize($imageObj->getImageStorageLocation());
     unset($imageObj);
     $imageOptions = '';
     $preferencesService = \Zend_Registry::get('container')->getService('system_preferences_service');
     if (array_key_exists('sub', $detailsArray)) {
         if ($preferencesService->MediaRichTextCaptions == 'Y') {
             $detailsArray['sub'] = html_entity_decode($detailsArray['sub'], ENT_QUOTES, 'UTF-8');
         } else {
             $detailsArray['sub'] = strip_tags(html_entity_decode($detailsArray['sub'], ENT_QUOTES, 'UTF-8'));
         }
     }
     $defaultOptions = array('ratio' => 'EditorImageRatio', 'width' => 'EditorImageResizeWidth', 'height' => 'EditorImageResizeHeight');
     foreach (array('ratio', 'width', 'height') as $imageOption) {
         $defaultOption = (int) $preferencesService->get($defaultOptions[$imageOption]);
         if (isset($detailsArray[$imageOption]) && $detailsArray[$imageOption] > 0) {
             if (strpos($detailsArray[$imageOption], '%') === false) {
                 $imageOptions .= " {$imageOption} " . (int) $detailsArray[$imageOption];
                 $detailsArray[$imageOption] = $detailsArray[$imageOption] . "px";
             }
         } elseif ($imageOption != 'ratio' && $defaultOption > 0) {
             $imageOptions .= " {$imageOption} {$defaultOption}";
         } elseif ($imageOption == 'ratio' && $defaultOption != 100) {
             $imageOptions .= " {$imageOption} {$defaultOption}";
         }
     }
     $imageOptions = trim($imageOptions);
     $imgZoomLink = '';
     if ($preferencesService->EditorImageZoom == 'Y' && strlen($imageOptions) > 0) {
         $imgZoomLink = '/' . $image->filerpath;
     }
     try {
         $templatesService = \Zend_Registry::get('container')->getService('newscoop.templates.service');
         $smarty = $templatesService->getSmarty();
         $uri->uri_parameter = "image {$imageOptions}";
         $smarty->assign('imageDetails', $detailsArray);
         $smarty->assign('MediaRichTextCaptions', $preferencesService->MediaRichTextCaptions);
         $smarty->assign('uri', $uri);
         $smarty->assign('imgZoomLink', $imgZoomLink);
         return $templatesService->fetchTemplate("editor_image.tpl");
     } catch (\Exception $e) {
         return $e->getMessage();
     }
 }
コード例 #6
0
ファイル: edit.php プロジェクト: nidzix/Newscoop
function parseTextBody($text, $articleNumber)
{
    // Subheads
    $text = preg_replace("/<!\\*\\*\\s*Title\\s*>/i", "<span class=\"campsite_subhead\">", $text);
    $text = preg_replace("/<!\\*\\*\\s*EndTitle\\s*>/i", "</span>", $text);
    // Internal Links with targets
    $text = preg_replace("/<!\\*\\*\\s*Link\\s*Internal\\s*([\\w=&]*)\\s*target[\\s\"]*([\\w_]*)[\\s\"]*>/i", '<a href="/campsite/campsite_internal_link?$1" target="$2">', $text);
    // Internal Links without targets
    $text = preg_replace("/<!\\*\\*\\s*Link\\s*Internal\\s*([\\w=&]*)\\s*>/i", '<a href="/campsite/campsite_internal_link?$1">', $text);
    // External Links (old style 2.1) with targets
    $text = preg_replace("/<!\\*\\*\\s*Link\\s*External[\\s\"]*([^\\s\"]*)[\\s\"]*target[\\s\"]*([\\w_]*)[\\s\"]*>/i", '<a href="$1" target="$2">', $text);
    // External Links (old style 2.1) without targets
    $text = preg_replace("/<!\\*\\*\\s*Link\\s*External[\\s\"]*([^\\s\"]*)[\\s\"]*>/i", '<a href="$1">', $text);
    // End link
    $text = preg_replace("/<!\\*\\*\\s*EndLink\\s*>/i", "</a>", $text);
    // Images
    preg_match_all("/<!\\*\\*\\s*Image\\s*([\\d]*)\\s*/i", $text, $imageMatches);
    preg_match_all("/\\s*sub=\"(.*?)\"/", $text, $titles);
    preg_match_all("/<!\\*\\*\\s*Image\\s*([\\d]*)\\s*(.*?)\\s*ratio=\"(.*?)\"/", $text, $ratios);
    if (isset($imageMatches[1][0])) {
        if (isset($titles) && sizeof($titles) > 0) {
            for ($x = 0; $x < sizeof($titles[0]); $x++) {
                $text = preg_replace("/\\s*" . preg_replace('~\\/~', '\\/', preg_quote($titles[0][$x])) . "/", ' title="' . $titles[1][$x] . '"', $text);
            }
        }
        $formattingErrors = FALSE;
        foreach ($imageMatches[1] as $templateId) {
            // Get the image URL
            $articleImage = new ArticleImage($articleNumber, NULL, $templateId);
            if (!$articleImage->exists()) {
                ArticleImage::RemoveImageTagsFromArticleText($articleNumber, $templateId);
                $formattingErrors = TRUE;
                continue;
            }
            $image = new Image($articleImage->getImageId());
            $imageUrl = $image->getImageUrl();
            unset($fakeTemplateId);
            if (isset($ratios) && sizeof($ratios) > 0) {
                $n = 0;
                foreach ($ratios[3] as $ratio) {
                    if ($ratios[1][$n++] == $templateId) {
                        $fakeTemplateId = $templateId . '_' . $ratio;
                    }
                }
            }
            if (!isset($fakeTemplateId)) {
                $fakeTemplateId = $templateId;
            }
            $text = preg_replace("/<!\\*\\*\\s*Image\\s*" . $templateId . "\\s+/i", '<img src="' . $imageUrl . '" id="' . $fakeTemplateId . '" ', $text);
        }
        if ($formattingErrors) {
            print '<script type="text/javascript">window.location.reload();</script>';
        }
    }
    return $text;
}
コード例 #7
0
ファイル: CampURI.php プロジェクト: nistormihai/Newscoop
    /**
     * Sets the URI path and query values based on given parameters.
     *
     * @param array $p_params
     *      An array of valid URL parameters
     * @param boolean $p_preview
     *      If true, will keep the preview parameters in the URL
     *
     * @return void
     */
    protected function buildURI(array &$p_params = array(), $p_preview = false) {
        if ($this->isValidCache()) {
            return;
        }

        if (count($p_params) == 0) {
            return;
        }
        $parameter = strtolower(array_shift($p_params));

        switch ($parameter) {
            case 'root_level':
                $this->m_buildPath = $this->m_config->getSetting('SUBDIR').'/';
                if ($p_preview) {
                    $this->m_buildQueryArray = $this->getQueryArray(CampURI::$m_previewParameters);
                } else {
                    $this->m_buildQueryArray = array();
                }
                $p_params = array();
                break;
            case 'articleattachment':
                $context = CampTemplate::singleton()->context();
                $attachment = new Attachment($context->attachment->identifier);
                $this->m_buildPath = $attachment->getAttachmentUri();
                $this->m_buildQueryArray = array();
                $p_params = array();
                break;
            case 'articlecomment':
                $context = CampTemplate::singleton()->context();
                if ($context->comment->defined) {
                    $this->m_buildQueryArray['acid'] = $context->comment->identifier;
                }
                break;
            case 'image':
                $this->m_buildQueryArray = array();
                if (isset($p_params[0]) && is_numeric($p_params[0])) {
                    $this->processOldImageOptions($imageNo, $p_params);
                } else {
                    $this->processImageOptions($imageNo, $p_params);
                }

                $context = CampTemplate::singleton()->context();
                if (!is_null($imageNo)) {
                    $oldImage = $context->image;
                    $articleImage = new ArticleImage($context->article->number, null, $imageNo);
                    $context->image = new MetaImage($articleImage->getImageId());
                }
                $this->m_buildPath = $this->m_config->getSetting('SUBDIR').'/get_img';
                $this->m_validURI = $context->image->defined();
                $this->m_buildQueryArray['ImageId'] = $context->image->number;
                if (!is_null($imageNo)) {
                    $context->image = $oldImage;
                }
                $p_params = array();
                break;
            case 'previous_subtitle':
            case 'next_subtitle':
            case 'all_subtitles':
                $option = isset($p_params[0]) ? array_shift($p_params) : null;
                $article = CampTemplate::singleton()->context()->article;
                $subtitleNo = $article->current_subtitle_no($option);
                if (!$article->defined || (!is_null($subtitleNo) && !is_numeric($subtitleNo))) {
                    return;
                }
                $fieldObj = $article->$option;
                if (($parameter == 'previous_subtitle' && !$fieldObj->has_previous_subtitles)
                || ($parameter == 'next_subtitle' && !$fieldObj->has_next_subtitles)) {
                    return;
                }
                $subtitleURLId = $article->subtitle_url_id($option);
                if ($parameter == 'all_subtitles') {
                    $newSubtitleNo = 'all';
                } else {
                    $newSubtitleNo = $subtitleNo + ($parameter == 'previous_subtitle' ? -1 : 1);
                }
                $this->m_buildQueryArray[$subtitleURLId] = $newSubtitleNo;
                break;
            case 'previous_items':
            case 'next_items':
                $context = CampTemplate::singleton()->context();
                if ($context->current_list == null) {
                    return;
                }
                $listId = $context->current_list->id;
                $this->m_buildQueryArray[$listId] = ($parameter == 'previous_items' ?
                $context->current_list->previous_start : $context->current_list->next_start);
                if ($this->m_buildQueryArray[$listId] == 0) {
                    unset($this->m_buildQueryArray[$listId]);
                }
                break;
            case 'reset_issue_list':
                $context = CampTemplate::singleton()->context();
                $listIdPrefix = $context->list_id_prefix('IssuesList');
                $this->resetList($listIdPrefix);
                break;
            case 'reset_section_list':
                $context = CampTemplate::singleton()->context();
                $listIdPrefix = $context->list_id_prefix('SectionsList');
                $this->resetList($listIdPrefix);
                break;
            case 'reset_article_list':
                $context = CampTemplate::singleton()->context();
                $listIdPrefix = $context->list_id_prefix('ArticlesList');
                $this->resetList($listIdPrefix);
                break;
            case 'reset_searchresult_list':
                $context = CampTemplate::singleton()->context();
                $listIdPrefix = $context->list_id_prefix('SearchResultsList');
                $this->resetList($listIdPrefix);
                break;
            case 'reset_subtitle_list':
                $context = CampTemplate::singleton()->context();
                $listIdPrefix = $context->list_id_prefix('SubtitlesList');
                $this->resetList($listIdPrefix);
                break;
            default:
                ;
        }
    }
コード例 #8
0
ファイル: get_img.php プロジェクト: nistormihai/Newscoop
 * @author Holman Romero <*****@*****.**>
 * @copyright 2007 MDLF, Inc.
 * @license http://www.gnu.org/licenses/gpl.txt
 * @version $Revision$
 * @link http://www.sourcefabric.org
 */

/**
 * Includes
 */
$GLOBALS['g_campsiteDir'] = dirname(__FILE__);
require_once($GLOBALS['g_campsiteDir'].'/template_engine/classes/CampRequest.php');
require_once($GLOBALS['g_campsiteDir'].'/template_engine/classes/CampGetImage.php');
require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleImage.php');

// reads parameters from image link URI
$imageId = (int) CampRequest::GetVar('ImageId', null, 'get');
$articleNr = (int) CampRequest::GetVar('NrArticle', null, 'get');
$imageNr = (int) CampRequest::GetVar('NrImage', null, 'get');
$imageRatio = (int) CampRequest::GetVar('ImageRatio', null, 'get');
$imageResizeWidth = (int) CampRequest::GetVar('ImageWidth', null, 'get');
$imageResizeHeight = (int) CampRequest::GetVar('ImageHeight', null, 'get');

if (empty($imageId) && !empty($imageNr) && !empty($articleNr)) {
	$articleImage = new ArticleImage($articleNr, null, $imageNr);
	$imageId = $articleImage->getImageId();
}

$showImage = new CampGetImage($imageId, $imageRatio, $imageResizeWidth, $imageResizeHeight);

?>
コード例 #9
0
ファイル: MetaArticle.php プロジェクト: sourcefabric/newscoop
 /**
  * Returns an image meta object corresponding to the given index
  * of the image attachment inside the article. Returns an empty
  * meta image object if the image did not exist.
  *
  * @param  int       $p_imageIndex - the index of the image attachment in the article
  * @return MetaImage
  */
 public function image($p_imageIndex)
 {
     $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
     $imageCacheKey = $cacheService->getCacheKey(array('MetaImage', $this->m_dbObject->getArticleNumber(), $p_imageIndex), 'article');
     if ($cacheService->contains($imageCacheKey)) {
         return $cacheService->fetch($imageCacheKey);
     }
     $articleImage = new ArticleImage($this->m_dbObject->getArticleNumber(), null, $p_imageIndex);
     if (!$articleImage->exists()) {
         $metaImage = new MetaImage();
     } else {
         $metaImage = new MetaImage($articleImage->getImageId());
     }
     $cacheService->save($imageCacheKey, $metaImage);
     return $metaImage;
 }
コード例 #10
0
ファイル: edit.php プロジェクト: sourcefabric/newscoop
function parseTextBody($text, $articleNumber)
{
    $translator = \Zend_Registry::get('container')->getService('translator');
    // Subheads
    $text = preg_replace("/<!\\*\\*\\s*Title\\s*>/i", "<span class=\"campsite_subhead\">", $text);
    $text = preg_replace("/<!\\*\\*\\s*EndTitle\\s*>/i", "</span>", $text);
    // Internal Links with targets
    $text = preg_replace("/<!\\*\\*\\s*Link\\s*Internal\\s*([\\w=&]*)\\s*target[\\s\"]*([\\w_]*)[\\s\"]*>/i", '<a href="/campsite/campsite_internal_link?$1" target="$2">', $text);
    // Internal Links without targets
    $text = preg_replace("/<!\\*\\*\\s*Link\\s*Internal\\s*([\\w=&]*)\\s*>/i", '<a href="/campsite/campsite_internal_link?$1">', $text);
    // External Links (old style 2.1) with targets
    $text = preg_replace("/<!\\*\\*\\s*Link\\s*External[\\s\"]*([^\\s\"]*)[\\s\"]*target[\\s\"]*([\\w_]*)[\\s\"]*>/i", '<a href="$1" target="$2">', $text);
    // External Links (old style 2.1) without targets
    $text = preg_replace("/<!\\*\\*\\s*Link\\s*External[\\s\"]*([^\\s\"]*)[\\s\"]*>/i", '<a href="$1">', $text);
    // End link
    $text = preg_replace("/<!\\*\\*\\s*EndLink\\s*>/i", "</a>", $text);
    // Images
    preg_match_all("/<!\\*\\*\\s*Image\\s*([\\d]*)\\s*/i", $text, $imageMatches);
    preg_match_all("/\\s*sub=\"(.*?)\"/", $text, $titles);
    preg_match_all("/<!\\*\\*\\s*Image\\s*([\\d]*)\\s*(.*?)\\s*ratio=\"(.*?)\"/", $text, $ratios);
    // snippet tag format: <-- Snippet 1 -->
    $snippetPattern = '<\\-\\-\\sSnippet\\s([\\d]+)\\s\\-\\->';
    $text = preg_replace("/{$snippetPattern}/i", '<div data-snippet-id="$1" class="camp_snippet">' . $translator->trans('Snippet', array(), 'articles') . ' $1</div>', $text);
    if (isset($imageMatches[1][0])) {
        if (isset($titles) && sizeof($titles) > 0) {
            for ($x = 0; $x < sizeof($titles[0]); $x++) {
                $text = preg_replace("/\\s*" . preg_replace('~\\/~', '\\/', preg_quote($titles[0][$x])) . "/", ' title="' . htmlspecialchars($titles[1][$x], ENT_QUOTES, 'UTF-8') . '"', $text);
            }
        }
        $formattingErrors = FALSE;
        foreach ($imageMatches[1] as $templateId) {
            // Get the image URL
            $articleImage = new ArticleImage($articleNumber, NULL, $templateId);
            if (!$articleImage->exists()) {
                ArticleImage::RemoveImageTagsFromArticleText($articleNumber, $templateId);
                $formattingErrors = TRUE;
                continue;
            }
            $image = new Image($articleImage->getImageId());
            $imageUrl = $image->getImageUrl();
            unset($fakeTemplateId);
            if (isset($ratios) && sizeof($ratios) > 0) {
                $n = 0;
                foreach ($ratios[3] as $ratio) {
                    if ($ratios[1][$n++] == $templateId) {
                        $fakeTemplateId = $templateId . '_' . $ratio;
                    }
                }
            }
            if (!isset($fakeTemplateId)) {
                $fakeTemplateId = $templateId;
            }
            $text = preg_replace("/<!\\*\\*\\s*Image\\s*" . $templateId . "\\s+/i", '<img src="' . $imageUrl . '" id="' . $fakeTemplateId . '" ', $text);
        }
        if ($formattingErrors) {
            print '<script type="text/javascript">window.location.reload();</script>';
        }
    }
    return $text;
}
コード例 #11
0
ファイル: MetaArticle.php プロジェクト: alvsgithub/Newscoop
 public final function __get($p_property)
 {
     $property = $this->translateProperty($p_property);
     if ($this->m_state == 'type_name_error') {
         $this->m_state = null;
         return null;
     }
     if ($property == 'type' && $this->m_state == null) {
         $this->m_state = 'type';
         return $this;
     }
     if ($this->m_state == 'type') {
         if (strcasecmp($this->m_dbObject->getType(), $property) != 0) {
             $this->m_state = 'type_name_error';
         } else {
             $this->m_state = null;
         }
         return $this;
     }
     if (is_null($this->m_state) && $property != 'image_index' && strncasecmp('image', $property, 5) == 0 && strlen($property) > 5) {
         $imageNo = substr($property, 5);
         $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
         $cacheKey = $cacheService->getCacheKey(array('MetaImage', $this->m_dbObject->getArticleNumber(), $imageNo), 'article');
         if ($cacheService->contains($cacheKey)) {
             return $cacheService->fetch($cacheKey);
         } else {
             $articleImage = new ArticleImage($this->m_dbObject->getArticleNumber(), null, $imageNo);
             if (!$articleImage->exists()) {
                 $this->trigger_invalid_property_error($p_property);
                 $metaImage = new MetaImage();
             } else {
                 $metaImage = new MetaImage($articleImage->getImageId());
             }
             $cacheService->save($cacheKey, $metaImage);
             return $metaImage;
         }
     }
     try {
         if (array_search($property, $this->m_properties)) {
             $methodName = $this->m_getPropertyMethod;
             $propertyValue = $this->m_dbObject->{$methodName}($property);
         } elseif (array_key_exists($property, $this->m_customProperties)) {
             return $this->getCustomProperty($property);
         } else {
             // empty
             //$this->trigger_invalid_property_error($p_property);
             return null;
         }
         if (empty($propertyValue) || !is_string($propertyValue) || is_numeric($propertyValue)) {
             return $propertyValue;
         }
         if (count($this->m_skipFilter) == 0 || !in_array(strtolower($p_property), $this->m_skipFilter)) {
             $propertyValue = self::htmlFilter($propertyValue);
         }
         return $propertyValue;
     } catch (InvalidPropertyException $e) {
         $this->trigger_invalid_property_error($p_property);
         return null;
     }
 }