Inheritance: extends DatabaseObject, implements IGeoMap
Exemplo n.º 1
0
</head>
<body onLoad="return false;">
<div class="map_preview_serach">
<div class="map_mappart_outer_serach">
<div class="map_mappart_serach">
<div class="map_mapmenu_serach">
<a href="#" onClick="<?php 
echo Geo_Map::GetMapSearchCenter();
?>
 return false;"><?php 
putGS('show initial map view');
?>
</a>
</div><!-- end of map_mapmenu -->
<?php 
echo Geo_Map::GetMapSearchBody();
?>
</div><!-- end of map_mappart -->
</div><!-- end of map_mappart_outer -->
</div><!-- end of map_preview -->
<div class="map_search_rectangle">
<ol>Top left
<li>longitude: <span id="top_left_longitude"> </span></li>
<li>latitude: <span id="top_left_latitude"> </span></li>
</ol>
</div>
<div>
<ol>Bottom right
<li>longitude: <span id="bottom_right_longitude"> </span></li>
<li>latitude: <span id="bottom_right_latitude"> </span></li>
</ol>
Exemplo n.º 2
0
 /**
  * Get Map for this article
  *
  * @return Geo_Map
  */
 protected function getMap() {
     $map = Geo_Map::GetMapByArticle($this->m_dbObject->getProperty('Number'));
     return new MetaMap($map);
 }
Exemplo n.º 3
0
    /**
     * Returns an articles list based on the given parameters.
     *
     * @param array $p_parameters
     *    An array of ComparisonOperation objects
     * @param string $p_order
     *    An array of columns and directions to order by
     * @param integer $p_start
     *    The record number to start the list
     * @param integer $p_limit
     *    The offset. How many records from $p_start will be retrieved.
     * @param integer $p_count
     *    The total count of the elements; this count is computed without
     *    applying the start ($p_start) and limit parameters ($p_limit)
     *
     * @return array $articlesList
     *    An array of Article objects
     */
    public static function GetList(array $p_parameters, $p_order = null,
                                   $p_start = 0, $p_limit = 0, &$p_count, $p_skipCache = false)
    {
        global $g_ado_db;

        if (!$p_skipCache && CampCache::IsEnabled()) {
            $paramsArray['parameters'] = serialize($p_parameters);
            $paramsArray['order'] = (is_null($p_order)) ? 'null' : $p_order;
            $paramsArray['start'] = $p_start;
            $paramsArray['limit'] = $p_limit;
            $cacheListObj = new CampCacheList($paramsArray, __METHOD__);
            $articlesList = $cacheListObj->fetchFromCache();
            if ($articlesList !== false && is_array($articlesList)) {
                return $articlesList;
            }
        }

        $matchAllTopics = false;
        $hasTopics = array();
        $hasNotTopics = array();
        $selectClauseObj = new SQLSelectClause();
        $otherTables = array();

        // sets the name of the table for the this database object
        $tmpArticle = new Article();
        $articleTable = $tmpArticle->getDbTableName();
        $selectClauseObj->setTable($articleTable);
        unset($tmpArticle);

        $languageId = null;

        // parses the given parameters in order to build the WHERE part of
        // the SQL SELECT sentence
        foreach ($p_parameters as $param) {
            $comparisonOperation = self::ProcessListParameters($param, $otherTables);
            $leftOperand = strtolower($comparisonOperation['left']);
            if ($leftOperand == 'idlanguage' && $comparisonOperation['symbol'] == '=') {
                $languageId = $comparisonOperation['right'];
            }

            if (array_key_exists($leftOperand, Article::$s_regularParameters)) {
                // regular article field, having a direct correspondent in the
                // Article table fields
                $whereCondition = Article::$s_regularParameters[$leftOperand]
                    . ' ' . $comparisonOperation['symbol']
                    . " '" . $g_ado_db->escape($comparisonOperation['right']) . "' ";
                if ($leftOperand == 'reads'
                && strstr($comparisonOperation['symbol'], '=') !== false
                && $comparisonOperation['right'] == 0) {
                    $selectClauseObj->addConditionalWhere($whereCondition);
                    $isNullCond = Article::$s_regularParameters[$leftOperand]
                                . ' IS NULL';
                    $selectClauseObj->addConditionalWhere($isNullCond);
                } elseif ($leftOperand == 'type' && $comparisonOperation['symbol'] == '=' ) {
					$selectClauseObj->addConditionalWhere($whereCondition);
                } else {
                	$selectClauseObj->addWhere($whereCondition);
                }
            } elseif ($leftOperand == 'matchalltopics') {
                // set the matchAllTopics flag
                $matchAllTopics = true;
            } elseif ($leftOperand == 'topic') {
                // add the topic to the list of match/do not match topics depending
                // on the operator
                $topic = new Topic($comparisonOperation['right']);
                if ($topic->exists()) {
                    $topicIds = $topic->getSubtopics(true, 0);
                    $topicIds[] = $comparisonOperation['right'];
                    if ($comparisonOperation['symbol'] == '=') {
                        $hasTopics[] = $topicIds;
                    } else {
                        $hasNotTopics[] = $topicIds;
                    }
                }
            } elseif ($leftOperand == 'author') {
                $otherTables['ArticleAuthors'] = array('__JOIN' => ',');
                $author = Author::ReadName($comparisonOperation['right']);
                $symbol = $comparisonOperation['symbol'];
                $valModifier = strtolower($symbol) == 'like' ? '%' : '';

                $firstName = $g_ado_db->escape($author['first_name']);
                $lastName = $g_ado_db->escape($author['last_name']);
                $whereCondition = "ArticleAuthors.fk_author_id IN
                    (SELECT Authors.id
                     FROM Authors
                     WHERE CONCAT(Authors.first_name, ' ', Authors.last_name) $symbol
                         '$valModifier$firstName $lastName$valModifier')";
                $selectClauseObj->addWhere($whereCondition);
                $selectClauseObj->addWhere('Articles.Number = ArticleAuthors.fk_article_number');
                $selectClauseObj->addWhere('Articles.IdLanguage = ArticleAuthors.fk_language_id');
            } elseif ($leftOperand == 'search_phrase') {
                $searchQuery = ArticleIndex::SearchQuery($comparisonOperation['right']);
                $mainClauseConstraint = "(Articles.Number, Articles.IdLanguage) IN ( $searchQuery )";
                $selectClauseObj->addWhere($mainClauseConstraint);
            } elseif ($leftOperand == 'location') {
                $num = '[-+]?[0-9]+(?:\.[0-9]+)?';
                if (preg_match("/($num) ($num), ($num) ($num)/",
                    trim($comparisonOperation['right']), $matches)) {
                    $queryLocation = Geo_Map::GetGeoSearchSQLQuery(array(
                        array(
                            'latitude' => $matches[1],
                            'longitude' => $matches[2],
                        ), array(
                            'latitude' => $matches[3],
                            'longitude' => $matches[4],
                        ),
                    ));
                    $selectClauseObj->addWhere("Articles.Number IN ($queryLocation)");
                }
            } else {
                // custom article field; has a correspondence in the X[type]
                // table fields
                $sqlQuery = self::ProcessCustomField($comparisonOperation, $languageId);
                if (!is_null($sqlQuery)) {
                    $whereCondition = "Articles.Number IN (\n$sqlQuery        )";
                    $selectClauseObj->addWhere($whereCondition);
                }
            }
        }

        if (count($hasTopics) > 0 || count($hasNotTopics) > 0) {
            $typeAttributes = ArticleTypeField::FetchFields(null, null, 'topic', false,
            false, false, true, $p_skipCache);
        }
        if (count($hasTopics) > 0) {
            if ($matchAllTopics) {
                foreach ($hasTopics as $topicId) {
                    $sqlQuery = Article::BuildTopicSelectClause($topicId, $typeAttributes);
                    $whereCondition = "Articles.Number IN (\n$sqlQuery        )";
                    $selectClauseObj->addWhere($whereCondition);
                }
            } else {
                $sqlQuery = Article::BuildTopicSelectClause($hasTopics, $typeAttributes);
                $whereCondition = "Articles.Number IN (\n$sqlQuery        )";
                $selectClauseObj->addWhere($whereCondition);
            }
        }
        if (count($hasNotTopics) > 0) {
            $sqlQuery = Article::BuildTopicSelectClause($hasNotTopics, $typeAttributes);
            $whereCondition = "Articles.Number NOT IN (\n$sqlQuery        )";
            $selectClauseObj->addWhere($whereCondition);
        }

        // create the count clause object
        $countClauseObj = clone $selectClauseObj;

        if (!is_array($p_order)) {
            $p_order = array();
        }

        // sets the ORDER BY condition
        $p_order = array_merge($p_order, Article::$s_defaultOrder);
        $order = Article::ProcessListOrder($p_order, $otherTables, $otherWhereConditions);
        foreach ($order as $orderDesc) {
            $orderColumn = $orderDesc['field'];
            $orderDirection = $orderDesc['dir'];
            $selectClauseObj->addOrderBy($orderColumn . ' ' . $orderDirection);
        }
        if (count($otherTables) > 0) {
            foreach ($otherTables as $table=>$fields) {
            	$joinType = 'LEFT JOIN';
            	if (isset($fields['__JOIN'])) {
            		$joinType = $fields['__JOIN'];
            	}
                if (isset($fields['__TABLE_ALIAS'])) {
                    $tableAlias = $fields['__TABLE_ALIAS'];
                    $tableJoin = "\n    $joinType $table AS $tableAlias \n";
                } else {
                    $tableAlias = $table;
                    $tableJoin = "\n    $joinType $tableAlias \n";
                }
                $firstCondition = true;
                foreach ($fields as $parent=>$child) {
                    if ($parent == '__TABLE_ALIAS' || $parent == '__JOIN') {
                        continue;
                    }
                    $condOperator = $firstCondition ? ' ON ' : 'AND ';
                    if ($parent == '__CONST') {
                        $constTable = $child['table'];
                        $constField = $child['field'];
                        $value = $child['value'];
                        $negate = isset($child['negate']) ? $child['negate'] : false;
                        if (is_null($value)) {
                            $operator = $negate ? 'IS NOT' : 'IS';
                            $value = 'NULL';
                        } else {
                            $operator = $negate ? '!=' : '=';
                            $value = "'" . $g_ado_db->escape($value) . "'";
                        }
                        $tableJoin .= "        $condOperator`$constTable`.`$constField` $operator $value\n";
                    } else {
                        $tableJoin .= "        $condOperator`$articleTable`.`$parent` = `$tableAlias`.`$child`\n";
                    }
                    $firstCondition = false;
                }
                $selectClauseObj->addJoin($tableJoin);
                $countClauseObj->addJoin($tableJoin);
            }
        }
        // other where conditions needed for certain order options
        foreach ($otherWhereConditions as $whereCondition) {
            $selectClauseObj->addWhere($whereCondition);
            $countClauseObj->addWhere($whereCondition);
        }

        // gets the column list to be retrieved for the database table
        $selectClauseObj->addColumn('Articles.Number');
        $selectClauseObj->addColumn('Articles.IdLanguage');
        $countClauseObj->addColumn('COUNT(*)');

        // sets the LIMIT start and offset values
        $selectClauseObj->setLimit($p_start, $p_limit);

        // builds the SQL query
        $selectQuery = $selectClauseObj->buildQuery();
        $countQuery = $countClauseObj->buildQuery();

        // runs the SQL query
        $articles = $g_ado_db->GetAll($selectQuery);
        if (is_array($articles)) {
            $p_count = $g_ado_db->GetOne($countQuery);

            // builds the array of Article objects
            $articlesList = array();
            foreach ($articles as $article) {
                $articlesList[] = new Article($article['IdLanguage'], $article['Number']);
            }
        } else {
            $articlesList = array();
            $p_count = 0;
        }

        // stores articles list in cache
        if (!$p_skipCache && CampCache::IsEnabled()) {
            $cacheListObj->storeInCache($articlesList);
        }

        return $articlesList;
    } // fn GetList
Exemplo n.º 4
0
    $f_language_id = Input::Get('f_language_id', 'int', 0);
}
$f_article_number = Input::Get('f_article_number', 'int', 0);
$map_article_spec = '' . $f_article_number . '_' . $f_language_id;
if (!Input::IsValid()) {
    camp_html_display_error(getGS('Invalid input: $1', Input::GetErrorString()), $_SERVER['REQUEST_URI'], true);
    exit;
}
$articleObj = new Article($f_language_id, $f_article_number);
$cnf_html_dir = $Campsite['HTML_DIR'];
$cnf_website_url = $Campsite['WEBSITE_URL'];
$geo_map_info = Geo_Preferences::GetMapInfo($cnf_html_dir, $cnf_website_url);
$geo_map_incl = Geo_Preferences::PrepareMapIncludes($geo_map_info['incl_obj']);
$geo_map_json = "";
$geo_map_json .= json_encode($geo_map_info['json_obj']);
$geo_map_usage = Geo_Map::ReadMapInfo('article', $f_article_number);
$geo_map_usage_json = "";
$geo_map_usage_json .= json_encode($geo_map_usage);
$geo_icons_info = Geo_Preferences::GetIconsInfo($cnf_html_dir, $cnf_website_url);
$geo_icons_json = "";
$geo_icons_json .= json_encode($geo_icons_info['json_obj']);
$geo_popups_info = Geo_Preferences::GetPopupsInfo($cnf_html_dir, $cnf_website_url);
$geo_popups_json = "";
$geo_popups_json .= json_encode($geo_popups_info['json_obj']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="Expires" content="now" />
    <title><?php 
Exemplo n.º 5
0
 /**
  * Gives the body map-info and point-list part for the map front end presentation
  *
  * @param int $p_languageId
  * @param array $p_constraints
  * @param array $p_options
  * @param int $p_offset
  * @param int $p_limit
  * @param int $p_rank
  *    The rank of the current multi-map, used to make unique ids
  *
  * @return array
  */
 public static function GetMultiMapTagListData($p_languageId, $p_constraints, $p_options, $p_offset, $p_limit, $p_rank = 0)
 {
     $f_language_id = (int) $p_languageId;
     $map_suffix = '_' . 'multimap' . '_' . $f_language_id . '_' . $p_rank;
     $preview = true;
     $text_only = true;
     $geo_map_usage = Geo_Map::ReadMultiMapInfo();
     $points = null;
     $pois_loaded = false;
     if (is_array($p_options)) {
         if (array_key_exists('pois_retrieved', $p_options)) {
             $pois_loaded = $p_options['pois_retrieved'];
         }
     }
     if (!$pois_loaded) {
         $leftOperand = 'as_array';
         $rightOperand = true;
         $operator = new Operator('is', 'php');
         $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand);
         $p_constraints[] = $constraint;
         $leftOperand = 'active_only';
         $rightOperand = true;
         $operator = new Operator('is', 'php');
         $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand);
         $p_constraints[] = $constraint;
         $leftOperand = 'text_only';
         $rightOperand = true;
         $operator = new Operator('is', 'php');
         $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand);
         $p_constraints[] = $constraint;
         $leftOperand = 'language';
         $rightOperand = $p_languageId;
         $operator = new Operator('is', 'php');
         $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand);
         $p_constraints[] = $constraint;
         $leftOperand = 'constrained';
         $rightOperand = true;
         $operator = new Operator('is', 'php');
         $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand);
         $p_constraints[] = $constraint;
         $poi_count = 0;
         $points = array();
         $point_objs = Geo_MapLocation::GetListExt($p_constraints, (array) null, $p_offset, $p_limit, $poi_count, false, $points);
     } else {
         $points = $p_constraints;
     }
     $poi_info = array('pois' => $points, 'map' => $geo_map_usage);
     $pind = 0;
     foreach ($poi_info['pois'] as $rank => $poi) {
         $cur_lon = $poi['longitude'];
         $cur_lat = $poi['latitude'];
         $center_poi = "if (window.map_prepared) {geo_object{$map_suffix}.center_lonlat({$cur_lon}, {$cur_lat});} point_large_map_center" . $map_suffix . "({$pind}, false);";
         $select_poi = "if (window.map_prepared) {geo_object{$map_suffix}.select_poi({$pind});} point_large_map_center" . $map_suffix . "({$pind}, true);";
         $poi_info['pois'][$rank]['center'] = $center_poi;
         $poi_info['pois'][$rank]['open'] = $select_poi;
         $pind += 1;
     }
     return (array) $poi_info;
 }
Exemplo n.º 6
0
$f_language_id = Input::Get('f_language_id', 'int', 0);
$f_language_selected = Input::Get('f_language_selected', 'int', 0);
$f_article_number = Input::Get('f_article_number', 'int', 0);

// Check input
if (!Input::IsValid()) {
	camp_html_display_error(getGS('Invalid input: $1', Input::GetErrorString()), null, true);
	exit;
}

// This file can only be accessed if the user has the right to change articles
// or the user created this article and it hasnt been published yet.
if (!$g_user->hasPermission('ChangeArticle')) {
	camp_html_display_error(getGS("You do not have the right to remove maps from articles."), null, true);
	exit;
}

$language_usage = $f_language_selected;
if ((!$language_usage) || (0 == $language_usage))
{
    $language_usage = $f_language_id;
}

$articleObj = new Article($f_language_selected, $f_article_number);
Geo_Map::UnlinkArticle($articleObj);

camp_html_add_msg(getGS('The map has been removed from the article.'), "ok");
camp_html_goto_page(camp_html_article_url($articleObj, $f_language_id, 'edit.php'));
?>
Exemplo n.º 7
0
</div>
<div class="clear" style="height:10px;"></div>
<!-- Map Preview Begin -->
<div class="geomap_container">
  <div class="geomap_locations">
    <?php 
echo Geo_Map::GetMapTagList($f_article_number, $f_language_id);
?>
  </div>
  <div class="geomap_menu">
    <a href="#" class="ui-state-default text-button" onClick="<?php 
echo Geo_Map::GetMapTagCenter($f_article_number, $f_language_id);
?>
 return false;"><?php 
putGS('show initial map view');
?>
</a>
  </div>
  <div class="geomap_map">
    <div class="geomap_menu">
        <?php 
echo Geo_Map::GetMapTagBody($f_article_number, $f_language_id);
?>
    </div>
  </div>
</div>
<div style="clear:both" ></div>
<!-- Map Preview End //-->
</body>
</html>
Exemplo n.º 8
0
 /**
  * Process item
  * @param  Article $article
  * @return array
  */
 public function processItem($article)
 {
     global $g_user, $Campsite;
     $translator = \Zend_Registry::get('container')->getService('translator');
     $editorService = \Zend_Registry::get('container')->getService('newscoop.editor');
     $articleLink = $editorService->getLink($article);
     $articleLinkParams = $editorService->getLinkParameters($article);
     $articleLinkParamsTranslate = $articleLinkParams . '&amp;f_action=translate&amp;f_action_workflow=' . $article->getWorkflowStatus() . '&amp;f_article_code=' . $article->getArticleNumber() . '_' . $article->getLanguageId();
     $previewLink = $Campsite['WEBSITE_URL'] . '/admin/articles/preview.php' . $editorService->getLinkParameters($article);
     $htmlPreviewLink = '<a href="' . $previewLink . '" target="_blank" title="' . $translator->trans('Preview') . '">' . $translator->trans('Preview') . '</a>';
     $translateLink = $Campsite['WEBSITE_URL'] . '/admin/articles/translate.php' . $articleLinkParamsTranslate;
     $htmlTranslateLink = '<a href="' . $translateLink . '" target="_blank" title="' . $translator->trans('Translate') . '">' . $translator->trans('Translate') . '</a>';
     $lockInfo = '';
     $lockHighlight = false;
     $timeDiff = camp_time_diff_str($article->getLockTime());
     if ($article->isLocked() && $timeDiff['days'] <= 0) {
         $lockUser = new User($article->getLockedByUser());
         if ($timeDiff['hours'] > 0) {
             $lockInfo = $translator->trans('The article has been locked by $1 ($2) $3 hour(s) and $4 minute(s) ago.', array('$1' => htmlspecialchars($lockUser->getRealName()), '$2' => htmlspecialchars($lockUser->getUserName()), '$3' => $timeDiff['hours'], '$4' => $timeDiff['minutes']), 'articles');
         } else {
             $lockInfo = $translator->trans('The article has been locked by $1 ($2) $3 minute(s) ago.', array('$1' => htmlspecialchars($lockUser->getRealName()), '$2' => htmlspecialchars($lockUser->getUserName()), '$3' => $timeDiff['minutes']), 'articles');
         }
         if ($article->getLockedByUser() != $g_user->getUserId()) {
             $lockHighlight = true;
         }
     }
     $tmpUser = new User($article->getCreatorId());
     $tmpArticleType = new ArticleType($article->getType());
     $tmpAuthor = new Author();
     $articleAuthors = ArticleAuthor::GetAuthorsByArticle($article->getArticleNumber(), $article->getLanguageId());
     foreach ((array) $articleAuthors as $author) {
         if (strtolower($author->getAuthorType()->getName()) == 'author') {
             $tmpAuthor = $author;
             break;
         }
     }
     if (!$tmpAuthor->exists() && isset($articleAuthors[0])) {
         $tmpAuthor = $articleAuthors[0];
     }
     $onFrontPage = $article->onFrontPage() ? $translator->trans('Yes') : $translator->trans('No');
     $onSectionPage = $article->onSectionPage() ? $translator->trans('Yes') : $translator->trans('No');
     $imagesNo = (int) ArticleImage::GetImagesByArticleNumber($article->getArticleNumber(), true);
     $topicsNo = (int) ArticleTopic::GetArticleTopics($article->getArticleNumber(), true);
     $commentsNo = '';
     if ($article->commentsEnabled()) {
         global $controller;
         $repositoryComments = $controller->getHelper('entity')->getRepository('Newscoop\\Entity\\Comment');
         $filter = array('thread' => $article->getArticleNumber(), 'language' => $article->getLanguageId());
         $params = array('sFilter' => $filter);
         $commentsNo = $repositoryComments->getCount($params);
     } else {
         $commentsNo = 'No';
     }
     // get language code
     $language = new Language($article->getLanguageId());
     return array($article->getArticleNumber(), $article->getLanguageId(), $article->getOrder(), sprintf('%s <a href="%s" title="%s %s">%s</a>', $article->isLocked() ? '<span class="ui-icon ui-icon-locked' . (!$lockHighlight ? ' current-user' : '') . '" title="' . $lockInfo . '"></span>' : '', $articleLink, $translator->trans('Edit'), htmlspecialchars($article->getName() . " ({$article->getLanguageName()})"), htmlspecialchars($article->getName() . (empty($_REQUEST['language']) ? " ({$language->getCode()})" : ''))), htmlspecialchars($article->getSection()->getName()), $article->getWebcode(), htmlspecialchars($tmpArticleType->getDisplayName()), htmlspecialchars($tmpUser->getRealName()), htmlspecialchars($tmpAuthor->getName()), $article->getWorkflowStatus(), $onFrontPage, $onSectionPage, $imagesNo, $topicsNo, $commentsNo, (int) $article->getReads(), Geo_Map::GetArticleMapId($article) != null ? $translator->trans('Yes') : $translator->trans('No'), (int) sizeof(Geo_Map::GetLocationsByArticle($article)), $article->getCreationDate(), $article->getPublishDate(), $article->getLastModified(), $htmlPreviewLink, $htmlTranslateLink);
 }
Exemplo n.º 9
0
 /**
  * Returns an articles list based on the given parameters.
  *
  * @param array   $p_parameters
  *                              An array of ComparisonOperation objects
  * @param string  $p_order
  *                              An array of columns and directions to order by
  * @param integer $p_start
  *                              The record number to start the list
  * @param integer $p_limit
  *                              The offset. How many records from $p_start will be retrieved.
  * @param integer $p_count
  *                              The total count of the elements; this count is computed without
  *                              applying the start ($p_start) and limit parameters ($p_limit)
  *
  * @return array $articlesList
  *               An array of Article objects
  */
 public static function GetList(array $p_parameters, $p_order = null, $p_start = 0, $p_limit = 0, &$p_count, $p_skipCache = false, $returnObjs = true)
 {
     global $g_ado_db;
     if (!$p_skipCache && CampCache::IsEnabled()) {
         $paramsArray['parameters'] = serialize($p_parameters);
         $paramsArray['order'] = is_null($p_order) ? 'null' : $p_order;
         $paramsArray['start'] = $p_start;
         $paramsArray['limit'] = $p_limit;
         $cacheListObj = new CampCacheList($paramsArray, __METHOD__);
         $articlesList = $cacheListObj->fetchFromCache();
         if ($articlesList !== false && is_array($articlesList)) {
             return $articlesList;
         }
     }
     $matchAllTopics = false;
     $hasTopics = array();
     $hasNotTopics = array();
     $selectClauseObj = new SQLSelectClause();
     $otherTables = array();
     // sets the name of the table for the this database object
     $tmpArticle = new Article();
     $articleTable = $tmpArticle->getDbTableName();
     $selectClauseObj->setTable($articleTable);
     unset($tmpArticle);
     $languageId = null;
     $em = Zend_Registry::get('container')->getService('em');
     $request = Zend_Registry::get('container')->getService('request');
     $repository = $em->getRepository('Newscoop\\NewscoopBundle\\Entity\\Topic');
     // parses the given parameters in order to build the WHERE part of
     // the SQL SELECT sentence
     foreach ($p_parameters as $param) {
         $comparisonOperation = self::ProcessListParameters($param, $otherTables);
         $leftOperand = strtolower($comparisonOperation['left']);
         if ($leftOperand == 'idlanguage' && $comparisonOperation['symbol'] == '=') {
             $languageId = $comparisonOperation['right'];
         }
         if (array_key_exists($leftOperand, Article::$s_regularParameters)) {
             // regular article field, having a direct correspondent in the
             // Article table fields
             $whereCondition = Article::$s_regularParameters[$leftOperand] . ' ' . $comparisonOperation['symbol'] . " " . $g_ado_db->escape($comparisonOperation['right']) . " ";
             if ($leftOperand == 'reads' && strstr($comparisonOperation['symbol'], '=') !== false && $comparisonOperation['right'] == 0) {
                 $selectClauseObj->addConditionalWhere($whereCondition);
                 $isNullCond = Article::$s_regularParameters[$leftOperand] . ' IS NULL';
                 $selectClauseObj->addConditionalWhere($isNullCond);
             } elseif ($leftOperand == 'type' && $comparisonOperation['symbol'] == '=') {
                 $selectClauseObj->addConditionalWhere($whereCondition);
             } elseif ($leftOperand == 'workflow_status' && isset($comparisonOperation['pending'])) {
                 $selectClauseObj->addConditionalWhere('Articles.NrIssue = 0');
                 $selectClauseObj->addConditionalWhere('Articles.NrSection = 0');
                 $selectClauseObj->addWhere($whereCondition);
             } else {
                 $selectClauseObj->addWhere($whereCondition);
             }
         } elseif ($leftOperand == 'matchalltopics') {
             // set the matchAllTopics flag
             $matchAllTopics = true;
         } elseif ($leftOperand == 'topic') {
             // add the topic to the list of match/do not match topics depending
             // on the operator
             $topic = $repository->getTopicByIdOrName($comparisonOperation['right'], $request->getLocale())->getOneOrNullResult();
             if ($topic) {
                 $topicIds = array();
                 foreach ($topic->getChildren() as $child) {
                     $topicIds[] = $child->getId();
                 }
                 $topicIds[] = $comparisonOperation['right'];
                 if ($comparisonOperation['symbol'] == '=') {
                     $hasTopics[] = $topicIds;
                 } else {
                     $hasNotTopics[] = $topicIds;
                 }
             }
         } elseif ($leftOperand == 'topic_strict') {
             $topic = $repository->getTopicByIdOrName($comparisonOperation['right'], $request->getLocale())->getOneOrNullResult();
             if ($topic) {
                 $topicIds[] = $comparisonOperation['right'];
                 if ($comparisonOperation['symbol'] == '=') {
                     $hasTopics[] = $topicIds;
                 } else {
                     $hasNotTopics[] = $topicIds;
                 }
             }
         } elseif ($leftOperand == 'author') {
             $otherTables['ArticleAuthors'] = array('__JOIN' => ',');
             $author = Author::ReadName($comparisonOperation['right']);
             $symbol = $comparisonOperation['symbol'];
             $valModifier = strtolower($symbol) == 'like' ? '%' : '';
             $firstName = trim(trim($g_ado_db->escape($author['first_name']), "'"));
             $lastName = trim(trim($g_ado_db->escape($author['last_name']), "'"));
             $authors = $g_ado_db->GetAll("\n                    SELECT Authors.id\n                    FROM Authors\n                    WHERE CONCAT(Authors.first_name, ' ', Authors.last_name) {$symbol}\n                         '{$valModifier}{$firstName} {$lastName}{$valModifier}'\n                ");
             $authorsIds = array();
             foreach ($authors as $author) {
                 $authorsIds[] = $author['id'];
             }
             $whereCondition = "ArticleAuthors.fk_author_id IN (" . implode(',', $authorsIds) . ")";
             $selectClauseObj->addWhere($whereCondition);
             $selectClauseObj->addWhere('Articles.Number = ArticleAuthors.fk_article_number');
             $selectClauseObj->addWhere('Articles.IdLanguage = ArticleAuthors.fk_language_id');
         } elseif ($leftOperand == 'search_phrase') {
             $searchQuery = ArticleIndex::SearchQuery($comparisonOperation['right'], $comparisonOperation['symbol']);
             if (!empty($searchQuery)) {
                 $otherTables["({$searchQuery})"] = array('__TABLE_ALIAS' => 'search', '__JOIN' => 'INNER JOIN', 'Number' => 'NrArticle', 'IdLanguage' => 'IdLanguage');
             }
         } elseif ($leftOperand == 'location') {
             $num = '[-+]?[0-9]+(?:\\.[0-9]+)?';
             if (preg_match("/({$num}) ({$num}), ({$num}) ({$num})/", trim($comparisonOperation['right']), $matches)) {
                 $queryLocation = Geo_Map::GetGeoSearchSQLQuery(array(array('latitude' => $matches[1], 'longitude' => $matches[2]), array('latitude' => $matches[3], 'longitude' => $matches[4])));
                 $selectClauseObj->addWhere("Articles.Number IN ({$queryLocation})");
             }
         } elseif ($leftOperand == 'insection') {
             $selectClauseObj->addWhere("Articles.NrSection IN " . $comparisonOperation['right']);
         } elseif ($leftOperand == 'complex_date') {
             /* @var $param ComparisonOperation */
             $fieldName = key($roper = $param->getRightOperand());
             $searchValues = array();
             foreach (explode(",", current($roper)) as $values) {
                 list($key, $value) = explode(":", $values, 2);
                 $searchValues[preg_replace("`(?<=[a-z])(_([a-z]))`e", "strtoupper('\\2')", trim($key))] = trim($value);
             }
             $repo = Zend_Registry::get('container')->getService('em')->getRepository('Newscoop\\Entity\\ArticleDatetime');
             /* @var $repo \Newscoop\Entity\Repository\ArticleRepository */
             $searchValues['fieldName'] = $fieldName;
             $sqlQuery = $repo->findDates((object) $searchValues, true)->getFindDatesSQL('dt.articleId');
             if (!is_null($sqlQuery)) {
                 $whereCondition = "Articles.Number IN (\n{$sqlQuery})";
                 $selectClauseObj->addWhere($whereCondition);
             }
         } else {
             // custom article field; has a correspondence in the X[type]
             // table fields
             $sqlQuery = self::ProcessCustomField($comparisonOperation, $languageId);
             if (!is_null($sqlQuery)) {
                 $whereCondition = "Articles.Number IN (\n{$sqlQuery}        )";
                 $selectClauseObj->addWhere($whereCondition);
             }
         }
     }
     if (count($hasTopics) > 0 || count($hasNotTopics) > 0) {
         $typeAttributes = ArticleTypeField::FetchFields(null, null, 'topic', false, false, false, true, $p_skipCache);
     }
     if (count($hasTopics) > 0) {
         if ($matchAllTopics) {
             foreach ($hasTopics as $topicId) {
                 $sqlQuery = Article::BuildTopicSelectClause($topicId, $typeAttributes);
                 $whereCondition = "Articles.Number IN (\n{$sqlQuery}        )";
                 $selectClauseObj->addWhere($whereCondition);
             }
         } else {
             $sqlQuery = Article::BuildTopicSelectClause($hasTopics, $typeAttributes);
             $whereCondition = "Articles.Number IN (\n{$sqlQuery}        )";
             $selectClauseObj->addWhere($whereCondition);
         }
     }
     if (count($hasNotTopics) > 0) {
         $sqlQuery = Article::BuildTopicSelectClause($hasNotTopics, $typeAttributes);
         $whereCondition = "Articles.Number NOT IN (\n{$sqlQuery}        )";
         $selectClauseObj->addWhere($whereCondition);
     }
     // create the count clause object
     $countClauseObj = clone $selectClauseObj;
     if (!is_array($p_order)) {
         $p_order = array();
     }
     // sets the ORDER BY condition
     $p_order = array_merge($p_order, Article::$s_defaultOrder);
     $order = Article::ProcessListOrder($p_order, $otherTables, $otherWhereConditions);
     foreach ($order as $orderDesc) {
         $orderColumn = $orderDesc['field'];
         $orderDirection = $orderDesc['dir'];
         $selectClauseObj->addOrderBy($orderColumn . ' ' . $orderDirection);
     }
     if (count($otherTables) > 0) {
         foreach ($otherTables as $table => $fields) {
             $joinType = 'LEFT JOIN';
             if (isset($fields['__JOIN'])) {
                 $joinType = $fields['__JOIN'];
             }
             if (isset($fields['__TABLE_ALIAS'])) {
                 $tableAlias = $fields['__TABLE_ALIAS'];
                 $tableJoin = "\n    {$joinType} {$table} AS {$tableAlias} \n";
             } else {
                 $tableAlias = $table;
                 $tableJoin = "\n    {$joinType} {$tableAlias} \n";
             }
             $firstCondition = true;
             foreach ($fields as $parent => $child) {
                 if ($parent == '__TABLE_ALIAS' || $parent == '__JOIN') {
                     continue;
                 }
                 $condOperator = $firstCondition ? ' ON ' : 'AND ';
                 if ($parent == '__CONST') {
                     $constTable = $child['table'];
                     $constField = $child['field'];
                     $value = $child['value'];
                     $negate = isset($child['negate']) ? $child['negate'] : false;
                     if (is_null($value)) {
                         $operator = $negate ? 'IS NOT' : 'IS';
                         $value = 'NULL';
                     } else {
                         $operator = $negate ? '!=' : '=';
                         $value = $g_ado_db->escape($value);
                     }
                     $tableJoin .= "        {$condOperator}`{$constTable}`.`{$constField}` {$operator} {$value}\n";
                 } else {
                     $tableJoin .= "        {$condOperator}`{$articleTable}`.`{$parent}` = `{$tableAlias}`.`{$child}`\n";
                 }
                 $firstCondition = false;
             }
             $selectClauseObj->addJoin($tableJoin);
             $countClauseObj->addJoin($tableJoin);
         }
     }
     // other where conditions needed for certain order options
     foreach ($otherWhereConditions as $whereCondition) {
         $selectClauseObj->addWhere($whereCondition);
         $countClauseObj->addWhere($whereCondition);
     }
     // gets the column list to be retrieved for the database table
     $selectClauseObj->addColumn('Articles.Number');
     $selectClauseObj->addColumn('Articles.IdLanguage');
     $countClauseObj->addColumn('COUNT(*)');
     // sets the LIMIT start and offset values
     $selectClauseObj->setLimit($p_start, $p_limit);
     // builds the SQL query
     $selectQuery = $selectClauseObj->buildQuery();
     $countQuery = $countClauseObj->buildQuery();
     // runs the SQL query
     $articles = $g_ado_db->GetAll($selectQuery);
     if (is_array($articles)) {
         $p_count = $g_ado_db->GetOne($countQuery);
         // builds the array of Article objects
         $articlesList = array();
         foreach ($articles as $article) {
             if ($returnObjs) {
                 $articlesList[] = new Article($article['IdLanguage'], $article['Number']);
             } else {
                 $articlesList[] = array('language_id' => $article['IdLanguage'], 'number' => $article['Number']);
             }
         }
     } else {
         $articlesList = array();
         $p_count = 0;
     }
     // stores articles list in cache
     if (!$p_skipCache && CampCache::IsEnabled()) {
         $cacheListObj->storeInCache($articlesList);
     }
     return $articlesList;
 }
Exemplo n.º 10
0
</div><!-- end of map_mappart_filter -->

</div><!-- end of map_mappart_outer_filter -->

<div class="geo_filter_texts" style="height:150px;overflow-y:auto;overflow-x:hidden">

<div class="polygon_info">
<div id="geo_polygons_info">&nbsp;</div>
</div><!-- end of polygon_info -->

<div class="polygon_append">
<form name="polygon_spec_new" action="#" onSubmit="<?php 
echo Geo_Map::GetMapFilterObjName();
?>
.add_polygon(polygon_spec_new.geo_polygon_new.value); return false;">
<a style="float:left" href='#' onclick='<?php 
echo Geo_Map::GetMapFilterObjName();
?>
.add_polygon(polygon_spec_new.geo_polygon_new.value); return false;'><span class="geo_add_polygon ui-icon ui-icon-plusthick"></span></a>
<input id="geo_polygon_new" class="geo_polygon_new" name="geo_polygon_new" size="80">
</form>
</div><!-- end of polygon_append -->

</div><!-- end of map_show_filter -->

</div><!-- end of geo_filter_texts -->

</body>
</html>

Exemplo n.º 11
0
/**
 * Campsite Map function plugin
 *
 * Type:     function
 * Name:     map
 * Purpose:  Render a geo map
 *
 * @param array
 *     $p_params List of parameters from template
 * @param object
 *     $p_smarty Smarty template object
 *
 * @return
 *     string The html content
 */
function smarty_function_map($p_params, &$p_smarty)
{
    // the strings are translated via Geo_Preferences::TemplateGeoStrings()
    // if you change some of the strings, put them there too
    $translator = \Zend_Registry::get('container')->getService('translator');
    // Default text for the reset link
    define('DEFAULT_RESET_TEXT', $translator->trans('Show original map', array(), 'api'));
    define('DEFAULT_OPEN_TEXT', $translator->trans('Open large map', array(), 'api'));
    // get the context variable
    $campsite = $p_smarty->getTemplateVars('gimme');
    $html = '';
    $map_common_header_set = $campsite->map_common_header_set;
    $map_load_common_header = !$map_common_header_set;
    // get show locations list parameter
    $showLocationsList = FALSE;
    if (isset($p_params['show_locations_list'])) {
        if (is_string($p_params['show_locations_list'])) {
            if (strtolower(trim((string) $p_params['show_locations_list'])) == 'true') {
                $showLocationsList = TRUE;
            }
        }
        if (is_bool($p_params['show_locations_list'])) {
            if ($p_params['show_locations_list']) {
                $showLocationsList = TRUE;
            }
        }
    }
    // get show reset link parameter
    $showResetLink = TRUE;
    $resetLinkText = DEFAULT_RESET_TEXT;
    if (isset($p_params['show_reset_link'])) {
        $resetLinkText_param = trim((string) $p_params['show_reset_link']);
        if ('1' != $resetLinkText_param && '0' != $resetLinkText_param) {
            $resetLinkText = $resetLinkText_param;
        }
        if (strtolower($resetLinkText_param) == 'false') {
            $showResetLink = FALSE;
        }
        if (empty($p_params['show_reset_link'])) {
            $showResetLink = FALSE;
        }
    }
    if (strtolower($resetLinkText) == 'true') {
        $resetLinkText = DEFAULT_RESET_TEXT;
    }
    // get show open link parameter
    $showOpenLink = TRUE;
    $openLinkText = DEFAULT_OPEN_TEXT;
    if (isset($p_params['show_open_link'])) {
        $openLinkText_param = trim((string) $p_params['show_open_link']);
        if ('1' != $openLinkText_param && '0' != $openLinkText_param) {
            $openLinkText = $openLinkText_param;
        }
        if (strtolower($openLinkText) == 'false') {
            $showOpenLink = FALSE;
        }
        if (empty($p_params['show_open_link'])) {
            $showOpenLink = FALSE;
        }
    }
    if (strtolower($openLinkText) == 'true') {
        $openLinkText = DEFAULT_OPEN_TEXT;
    }
    // should be the map a simple one, with opening the large map on any click
    $openMapOnClick = false;
    if (isset($p_params['open_map_on_click'])) {
        $openMapOnClick_param = strtolower(trim((string) $p_params['open_map_on_click']));
        if ('false' != $openMapOnClick_param && '0' != $openMapOnClick_param && !empty($p_params['open_map_on_click'])) {
            $openMapOnClick = true;
        }
    }
    // get map width and height
    $width_dyn = false;
    $height_dyn = false;
    $width = 0;
    $height = 0;
    if (isset($p_params['width'])) {
        $param_width = strtolower(trim((string) $p_params['width']));
        $param_width_arr = explode('%', $param_width);
        if (1 < count($param_width_arr)) {
            $width_dyn = true;
            $width = (int) $param_width_arr[0];
            if (100 < $width) {
                $width = 100;
            }
        } else {
            $width = (int) $p_params['width'];
        }
        if (0 > $width) {
            $width = 0;
        }
    }
    if (isset($p_params['height'])) {
        $param_height = strtolower(trim((string) $p_params['height']));
        $param_height_arr = explode('%', $param_height);
        if (1 < count($param_height_arr)) {
            $height_dyn = true;
            $height = (int) $param_height_arr[0];
            if (100 < $height) {
                $height = 100;
            }
        } else {
            $height = (int) $p_params['height'];
        }
        if (0 > $height) {
            $height = 0;
        }
    }
    $width_large = isset($p_params['popup_width']) ? (int) $p_params['popup_width'] : 800;
    $height_large = isset($p_params['popup_height']) ? (int) $p_params['popup_height'] : 600;
    $max_zoom = isset($p_params['max_zoom']) ? (int) $p_params['max_zoom'] : null;
    $map_margin = isset($p_params['map_margin']) ? (int) $p_params['map_margin'] : null;
    $area_show = isset($p_params['area_show']) ? (string) $p_params['area_show'] : null;
    // if we shall display a multi-map
    if (!is_null($campsite->map_dynamic_points_raw) || !is_null($campsite->map_dynamic_constraints)) {
        // language must be set in context
        if (!$campsite->language->defined) {
            return;
        }
        $offset = 0;
        $limit = $campsite->map_dynamic_max_points;
        if (!$limit) {
            $limit = 2000;
        }
        $multi_map_rank = $campsite->map_dynamic_id_counter;
        $map_language = (int) $campsite->language->number;
        $multi_map_part = "<!-- Begin Map //-->\n";
        $multi_map_body = '';
        $multi_map_header = '';
        $multi_poi_list = '';
        $multi_map_points = $campsite->map_dynamic_points_raw;
        $multi_map_label = $campsite->map_dynamic_map_label;
        $multi_options = array();
        $multi_options['max_zoom'] = $max_zoom;
        $multi_options['map_margin'] = $map_margin;
        $multi_options['load_common'] = $map_load_common_header;
        $multi_options['pois_retrieved'] = false;
        $multi_options['width_dyn'] = $width_dyn;
        $multi_options['height_dyn'] = $height_dyn;
        $multi_options['large_map_on_click'] = $openMapOnClick;
        $multi_options['large_map_open'] = $showOpenLink;
        $multi_options['large_map_width'] = $width_large;
        $multi_options['large_map_height'] = $height_large;
        $multi_options['large_map_label'] = $multi_map_label;
        if ($campsite->map_dynamic_areas) {
            if ('focus' == strtolower($area_show)) {
                $multi_options['area_points'] = $campsite->map_dynamic_areas;
            }
            if ('focus_empty' == strtolower($area_show)) {
                $multi_options['area_points'] = $campsite->map_dynamic_areas;
                $multi_options['area_points_empty_only'] = true;
            }
        }
        if ($multi_map_points) {
            $multi_options['pois_retrieved'] = true;
            $multi_map_header = Geo_Map::GetMultiMapTagHeader($map_language, $multi_map_points, $multi_options, $offset, $limit, $width, $height, $multi_map_rank);
            $multi_poi_list = Geo_Map::GetMultiMapTagList($map_language, $multi_map_points, $multi_options, $multi_map_label, $offset, $limit, $multi_map_rank);
        } else {
            $multi_map_constraints = $campsite->map_dynamic_constraints;
            $multi_map_header = Geo_Map::GetMultiMapTagHeader($map_language, $multi_map_constraints, $multi_options, $offset, $limit, $width, $height, $multi_map_rank);
            $multi_poi_list = Geo_Map::GetMultiMapTagList($map_language, $multi_map_constraints, $multi_options, $multi_map_label, $offset, $limit, $multi_map_rank);
        }
        $multi_map_center = Geo_Map::GetMultiMapTagCenter($map_language, $multi_map_rank);
        $multi_map_open = Geo_Map::GetMultiMapTagOpen($map_language, $multi_map_rank);
        $multi_map_div = Geo_Map::GetMultiMapTagBody($map_language, $multi_map_rank);
        $multi_map_body .= '
        <div class="geomap_container">';
        if ($showLocationsList == TRUE) {
            $multi_map_body .= '
                <div class="geomap_locations">
                    ' . $multi_poi_list . '
                </div>';
        }
        if ($showResetLink == TRUE) {
            $multi_map_body .= '
                <div class="geomap_menu">
                    <a href="#" onClick="' . $multi_map_center . 'return false;">' . camp_javascriptspecialchars($resetLinkText) . '</a>
                </div>';
        }
        if ($showOpenLink == TRUE) {
            $multi_map_body .= '
                <div class="geomap_open_large_map">
                    <a href="#" onClick="' . $multi_map_open . 'return false;">' . camp_javascriptspecialchars($openLinkText) . '</a>
                </div>';
        }
        $multi_map_body .= '
            <div class="geomap_map">
                ' . $multi_map_div . '
            </div>
        </div>
        <div style="clear:both" ></div>
        <!--End Map //-->
';
        $multi_map_part .= $multi_map_header . $multi_map_body;
        $campsite->map_common_header_set = true;
        return $multi_map_part;
    }
    // the end of the multi-map part; the article map is processed below
    // language and article must be set in context
    if (!$campsite->language->defined || !$campsite->article->defined) {
        return;
    }
    // do nothing if article does not have a map
    if ($campsite->article->has_map == FALSE) {
        return;
    }
    // get article and language from context
    $article = (int) $campsite->article->number;
    $language = (int) $campsite->language->number;
    $auto_focus = isset($p_params['auto_focus']) ? (bool) $p_params['auto_focus'] : null;
    // get core pieces to display the map
    $map_options = array();
    $map_options['auto_focus'] = $auto_focus;
    $map_options['max_zoom'] = $max_zoom;
    $map_options['map_margin'] = $map_margin;
    $map_options['load_common'] = $map_load_common_header;
    $map_options['width_dyn'] = $width_dyn;
    $map_options['height_dyn'] = $height_dyn;
    $map_options['large_map_on_click'] = $openMapOnClick;
    $map_options['large_map_open'] = $showOpenLink;
    $map_options['large_map_width'] = $width_large;
    $map_options['large_map_height'] = $height_large;
    $mapHeader = MetaMap::GetMapTagHeader($article, $language, $width, $height, $map_options);
    $mapMain = MetaMap::GetMapTagBody($article, $language);
    // build javascript code
    $html = '
        <!-- Begin Map //-->' . $mapHeader . '
        <div class="geomap_container">';
    if ($showLocationsList == TRUE) {
        $local = array('map' => $translator->trans('Map', array(), 'api'), 'center' => $translator->trans('Center', array(), 'api'));
        $mapLocationsList = MetaMap::GetMapTagList($article, $language, $local);
        $html .= '
            <div class="geomap_locations">' . $mapLocationsList . '
            </div>';
    }
    if ($showResetLink == TRUE) {
        $mapResetLink = MetaMap::GetMapTagCenter($article, $language);
        $html .= '
            <div class="geomap_menu">
                <a href="#" onClick="' . $mapResetLink . '
                 return false;">' . camp_javascriptspecialchars($resetLinkText) . '</a>
            </div>';
    }
    if ($showOpenLink == TRUE) {
        $mapOpenLink = Geo_Map::GetMapTagOpen($article, $language);
        $html .= '
            <div class="geomap_open_large_map">
                <a href="#" onClick="' . $mapOpenLink . 'return false;">' . camp_javascriptspecialchars($openLinkText) . '</a>
            </div>';
    }
    $html .= '
            <div class="geomap_map">' . $mapMain . '
            </div>
        </div>
        <div style="clear:both" ></div>
        <!--End Map //-->
    ';
    $campsite->map_common_header_set = true;
    return $html;
}
Exemplo n.º 12
0
 /**
  * @param int $p_article
  * @param int $p_language
  * @return string
  */
 public static function GetMapTagList($p_articleNumber, $p_languageId)
 {
     return Geo_Map::GetMapTagList((int) $p_articleNumber, (int) $p_languageId);
 }
Exemplo n.º 13
0
	/**
	 * Process item
	 * @param Article $article
	 * @return array
	 */
	public function processItem(Article $article)
	{
		global $g_user, $Campsite;

		$articleLinkParams = '?f_publication_id=' . $article->getPublicationId()
		. '&amp;f_issue_number=' . $article->getIssueNumber() . '&amp;f_section_number=' . $article->getSectionNumber()
		. '&amp;f_article_number=' . $article->getArticleNumber() . '&amp;f_language_id=' . $article->getLanguageId()
		. '&amp;f_language_selected=' . $article->getLanguageId();
		$articleLink = $Campsite['WEBSITE_URL'].'/admin/articles/edit.php' . $articleLinkParams;
		$previewLink = $Campsite['WEBSITE_URL'].'/admin/articles/preview.php' . $articleLinkParams;

		$lockInfo = '';
		$lockHighlight = false;
		$timeDiff = camp_time_diff_str($article->getLockTime());
		if ($article->isLocked() && ($timeDiff['days'] <= 0)) {
			$lockUser = new User($article->getLockedByUser());
			if ($timeDiff['hours'] > 0) {
				$lockInfo = getGS('The article has been locked by $1 ($2) $3 hour(s) and $4 minute(s) ago.',
				htmlspecialchars($lockUser->getRealName()),
				htmlspecialchars($lockUser->getUserName()),
				$timeDiff['hours'], $timeDiff['minutes']);
			} else {
				$lockInfo = getGS('The article has been locked by $1 ($2) $3 minute(s) ago.',
				htmlspecialchars($lockUser->getRealName()),
				htmlspecialchars($lockUser->getUserName()),
				$timeDiff['minutes']);
			}
			if ($article->getLockedByUser() != $g_user->getUserId()) {
				$lockHighlight = true;
			}
		}

		$tmpUser = new User($article->getCreatorId());
		$tmpArticleType = new ArticleType($article->getType());

		$tmpAuthor = new Author();
		$articleAuthors = ArticleAuthor::GetAuthorsByArticle($article->getArticleNumber(), $article->getLanguageId());
		foreach((array) $articleAuthors as $author) {
			if (strtolower($author->getAuthorType()->getName()) == 'author') {
				$tmpAuthor = $author;
				break;
			}
		}
		if (!$tmpAuthor->exists() && isset($articleAuthors[0])) {
			$tmpAuthor = $articleAuthors[0];
		}

		$onFrontPage = $article->onFrontPage() ? getGS('Yes') : getGS('No');
		$onSectionPage = $article->onSectionPage() ? getGS('Yes') : getGS('No');

		$imagesNo = (int) ArticleImage::GetImagesByArticleNumber($article->getArticleNumber(), true);
		$topicsNo = (int) ArticleTopic::GetArticleTopics($article->getArticleNumber(), true);
		$commentsNo = '';
		if ($article->commentsEnabled()) {
			$commentsNo = (int) ArticleComment::GetArticleComments($article->getArticleNumber(), $article->getLanguageId(), null, true);
		} else {
			$commentsNo = 'No';
		}

		// get language code
		$language = new Language($article->getLanguageId());

		return array(
		$article->getArticleNumber(),
		$article->getLanguageId(),
		$article->getOrder(),
		sprintf('%s <a href="%s" title="%s %s">%s</a>',
		$article->isLocked() ? '<span class="ui-icon ui-icon-locked' . (!$lockHighlight ? ' current-user' : '' ) . '" title="' . $lockInfo . '"></span>' : '',
		$articleLink,
		getGS('Edit'), $article->getName() . " ({$article->getLanguageName()})",
		$article->getName() . (empty($_REQUEST['language']) ? " ({$language->getCode()})" : '')),
		$tmpArticleType->getDisplayName(),
		$tmpUser->getRealName(),
		$tmpAuthor->getName(),
		$article->getWorkflowStatus(),
		$onFrontPage,
		$onSectionPage,
		$imagesNo,
		$topicsNo,
		$commentsNo,
		(int) $article->getReads(),
		Geo_Map::GetArticleMapId($article) != NULL ? getGS('Yes') : getGS('No'),
		(int) sizeof(Geo_Map::GetLocationsByArticle($article)),
		$article->getCreationDate(),
		$article->getPublishDate(),
		$article->getLastModified(),
		);
	}
Exemplo n.º 14
0
    /**
     * Gives the body map-info and point-list part for the map front end presentation
     *
     * @param int $p_articleNumber
     * @param int $p_languageId
     *
     * @return array
     */
    public static function GetMapTagListData($p_articleNumber, $p_languageId)
    {
        $f_article_number = (int) $p_articleNumber;
        $f_language_id = (int) $p_languageId;
        $map_suffix = "_" . $f_article_number . "_" . $f_language_id;
        $map_id = Geo_Map::GetMapIdByArticle($f_article_number);
        $preview = true;
        $text_only = true;

        $poi_info = Geo_Map::LoadMapData($map_id, $f_language_id, $f_article_number, $preview, $text_only);
        $pind = 0;
        foreach ($poi_info["pois"] as $rank => $poi) {
            $cur_lon = $poi["longitude"];
            $cur_lat = $poi["latitude"];
            $center = "geo_object$map_suffix.center_lonlat($cur_lon, $cur_lat);";
            $poi_info["pois"][$rank]["center"] = $center;
            $poi_info["pois"][$rank]["open"] = "geo_hook_on_map_feature_select(geo_object$map_suffix, $pind);";
            $pind += 1;
        }
        return (array) $poi_info;
    } // fn GetMapTagListData