Exemplo n.º 1
0
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $this->fields = $this->defFields();
     $storeVar = isset($_GET['act']) && $_GET['act'] == 'list';
     // if true store the filter variables
     $init = array_key_exists('init', $this->request);
     $reset = array_key_exists('reset', $this->request);
     if ($init || $reset) {
         $storeVar = true;
     }
     $this->id = initVar('id');
     $this->last_id = initVar('last_id');
     $this->parent_act = initVar('parent_act');
     $this->tab_mode = initVar('tab_mode');
     $this->act = initVar('act', 'list');
     $this->do_id = $_SESSION['do_id'];
     $this->gpr_id = initVar('gpr_id');
     $this->order = PageVar('order', '1A', $init, false, $this->baseName, $storeVar);
     $this->pg = PageVar('pg', 0, $init | $reset, false, $this->baseName, $storeVar);
     setLang(R3Locale::getLanguageCode());
     setLangInfo(array('thousands_sep' => "."));
     $this->registerAjaxFunction('submitFormData');
     $this->registerAjaxFunction('askDelGlobalPlainGauge');
 }
Exemplo n.º 2
0
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $this->fields = $this->defFields();
     $storeVar = isset($_GET['act']) && $_GET['act'] == 'list';
     // if true store the filter variables
     $init = array_key_exists('init', $this->request);
     $reset = array_key_exists('reset', $this->request);
     if ($init || $reset) {
         $storeVar = true;
     }
     $this->id = (int) initVar('id');
     $this->last_id = initVar('last_id');
     $this->act = initVar('act', 'list');
     $this->do_id = $_SESSION['do_id'];
     $this->mu_id = initvar('mu_id');
     $this->documentType = 'import_seap';
     $this->isDialog = false;
     // Cambia le azioni per edit / delete
     $this->parent_act = 'list';
     $this->order = PageVar('order', '1A', $init, false, $this->baseName, $storeVar);
     $this->registerAjaxFunction('checkImport');
     $this->registerAjaxFunction('confirmDeleteImport');
     $this->registerAjaxFunction('submitFormData');
 }
Exemplo n.º 3
0
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $this->fields = $this->defFields();
     $init = array_key_exists('init', $this->request);
     $reset = array_key_exists('reset', $this->request);
     $storeVar = isset($_GET['act']) && $_GET['act'] == 'list' || $reset || $init;
     // if true store the filter variables
     if ($init || $reset) {
         $storeVar = true;
     }
     $this->id = initVar('id');
     if (initVar('bu_id') !== null) {
         $this->id = initVar('bu_id');
     }
     $this->last_id = initVar('last_id');
     $this->parent_act = initVar('parent_act');
     $this->act = initVar('act', 'list');
     $this->do_id = $_SESSION['do_id'];
     $this->st_parent_id = PageVar('st_parent_id', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->st_name = PageVar('st_name', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->order = PageVar('order', '1A', $init, false, $this->baseName, $storeVar);
     $this->pg = PageVar('pg', 0, $init | $reset, false, $this->baseName, $storeVar);
     $this->registerAjaxFunction('submitFormData');
     $this->registerAjaxFunction('generateStatisticClass');
 }
Exemplo n.º 4
0
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $init = array_key_exists('init', $this->request);
     $reset = array_key_exists('reset', $this->request);
     $this->id = initVar('id');
     $this->ge_id = (int) initVar('ge_id');
     $this->gs_id = (int) initVar('gs_id');
     $this->gc_id = initVar('gc_id');
     $this->act = initVar('act', initVar('parent_act', 'mod'));
     $this->parent_act = initVar('parent_act', 'mod');
     $this->kind = strToUpper(initVar('kind'));
     $this->new_udm_divider = initVar('udm_divider');
     $this->merge_municipality_data = PageVar('merge_municipality_data', 'T') == 'T' ? true : false;
     $this->toggle_subcategory = initVar('toggle_subcategory');
     $this->do_id = PageVar('do_id', $_SESSION['do_id'], $init | $reset, false, $this->baseName);
     $this->pr_id = PageVar('pr_id', null, $init | $reset, false, $this->baseName);
     $this->mu_id = PageVar('mu_id', null, $init | $reset, false, $this->baseName);
     $this->bpu_id = PageVar('bpu_id', null, $init | $reset, false, $this->baseName);
     $this->order = PageVar('order', '1A', $init, false, $this->baseName);
     $this->pg = PageVar('pg', 0, $init | $reset, false, $this->baseName);
     setLang(R3Locale::getLanguageCode());
     setLangInfo(array('thousands_sep' => "."));
     $this->registerAjaxFunction('getHelp');
     $this->registerAjaxFunction('toggleSubcategory');
     $this->registerAjaxFunction('updateLastOpenCloseStatus');
 }
Exemplo n.º 5
0
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $this->fields = $this->defFields();
     $storeVar = isset($_GET['act']) && $_GET['act'] == 'list';
     // if true store the filter variables
     $init = array_key_exists('init', $this->request);
     $reset = array_key_exists('reset', $this->request);
     if ($init || $reset) {
         $storeVar = true;
     }
     $this->parent_act = initVar('parent_act');
     $this->id = initVar('id');
     $this->last_id = initVar('last_id');
     $this->act = initVar('act', 'list');
     $this->gs_id = initVar('gs_id');
     $this->do_id = PageVar('do_id', $_SESSION['do_id'], $init | $reset, false, $this->baseName, $storeVar);
     $this->pr_id = PageVar('pr_id', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->mu_id = PageVar('mu_id', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->mu_name = PageVar('mu_name', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->ge_name = PageVar('ge_name', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->ge_year = (int) PageVar('ge_year', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->order = PageVar('order', '1A', $init, false, $this->baseName, $storeVar);
     $this->pg = PageVar('pg', 0, $init | $reset, false, $this->baseName, $storeVar);
     $this->toggle_subcategory = initVar('toggle_subcategory');
     $this->registerAjaxFunction('getHelp');
     $this->registerAjaxFunction('submitFormData');
     $this->registerAjaxFunction('askDelGlobalResult');
 }
Exemplo n.º 6
0
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $this->act = 'mod';
     $this->module = PageVar('module', null, false, false, $this->baseName);
     $this->registerAjaxFunction('submitFormData');
     $this->registerAjaxFunction('resetTableColumnToDefault');
 }
Exemplo n.º 7
0
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $init = array_key_exists('init', $this->request);
     $reset = array_key_exists('reset', $this->request);
     $this->id = initVar('id');
     $this->act = initVar('act', 'list');
     $this->order = PageVar('order', '1A', $init, false, $this->baseName);
     $this->pg = PageVar('pg', 0, $init | $reset, false, $this->baseName);
     $this->registerAjaxFunction('getHelp');
     $this->registerAjaxFunction('submitFormData');
 }
Exemplo n.º 8
0
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $init = array_key_exists('init', $this->request);
     $reset = array_key_exists('reset', $this->request);
     $this->id = initVar('id');
     $this->act = initVar('act', 'show');
     $this->do_id = PageVar('do_id', $_SESSION['do_id'], $init | $reset, false, $this->baseName);
     $this->pr_id = PageVar('pr_id', null, $init | $reset, false, $this->baseName);
     $this->mu_id = PageVar('mu_id', null, $init | $reset, false, $this->baseName);
     $this->mu_name = PageVar('mu_name', null, $init | $reset, false, $this->baseName);
 }
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $init = array_key_exists('init', $this->request);
     $this->act = initVar('act', 'list');
     $this->sl_id = PageVar('sl_id');
     $this->last_id = initVar('consumption_last_id');
     $this->parent_act = PageVar('parent_act');
     $this->tab_mode = initVar('tab_mode');
     $this->order = PageVar('order', '6A', $init, false, $this->baseName);
     setLang(R3Locale::getLanguageCode());
     setLangInfo(array('thousands_sep' => "."));
 }
Exemplo n.º 10
0
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $this->fields = $this->defFields();
     $init = array_key_exists('init', $this->request);
     $reset = array_key_exists('reset', $this->request);
     $this->id = initVar('id');
     $this->act = initVar('act', 'list');
     $this->kind = PageVar('kind');
     $this->em_id = PageVar('em_id', null, $init | $reset, false, $this->baseName);
     $this->tabMode = PageVar('tab_mode', null, $init | $reset, false, $this->baseName);
     setLang(R3Locale::getLanguageCode());
     setLangInfo(array('thousands_sep' => "."));
     $this->registerAjaxFunction('confirm_delete_device');
     $this->registerAjaxFunction('submitFormData');
 }
Exemplo n.º 11
0
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $this->fields = $this->defFields();
     $init = array_key_exists('init', $this->request);
     $reset = array_key_exists('reset', $this->request);
     $storeVar = isset($_GET['act']) && $_GET['act'] == 'list' || $reset || $init;
     // if true store the filter variables
     if ($init || $reset) {
         $storeVar = true;
     }
     $this->id = initVar('id');
     if (initVar('bu_id') !== null) {
         $this->id = initVar('bu_id');
     }
     $this->last_id = initVar('last_id');
     $this->parent_act = initVar('parent_act');
     $this->act = initVar('act', 'list');
     $this->do_id = $_SESSION['do_id'];
     $this->pr_id = PageVar('pr_id', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->mu_id = PageVar('mu_id', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->mu_name = PageVar('mu_name', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->fr_id = PageVar('fr_id', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->fr_name = PageVar('fr_name', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->st_id = PageVar('st_id', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->st_name = PageVar('st_name', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->bu_civic = PageVar('bu_civic', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->bu_code = PageVar('bu_code', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->bu_name = PageVar('bu_name', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->bpu_id = PageVar('bpu_id', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->bt_id = PageVar('bt_id', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->bby_id = PageVar('bby_id', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->bry_id = PageVar('bry_id', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->bu_to_check = PageVar('bu_to_check', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->bu_alternative_simulation = PageVar('bu_alternative_simulation', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->order = PageVar('order', '1A', $init, false, $this->baseName, $storeVar);
     $this->pg = PageVar('pg', 0, $init | $reset, false, $this->baseName, $storeVar);
     $this->registerAjaxFunction('getHelp');
     $this->registerAjaxFunction('fetch_fr_st_cm');
     $this->registerAjaxFunction('fetch_fraction');
     $this->registerAjaxFunction('getStreetList');
     $this->registerAjaxFunction('fetch_catmunic');
     $this->registerAjaxFunction('fetch_municipality');
     $this->registerAjaxFunction('fetch_eneryClassLimit');
     $this->registerAjaxFunction('askDelBuilding');
     $this->registerAjaxFunction('submitFormData');
 }
Exemplo n.º 12
0
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $storeVar = isset($_GET['act']) && $_GET['act'] == 'list';
     // if true store the filter variables
     $init = array_key_exists('init', $this->request);
     $reset = array_key_exists('reset', $this->request);
     if ($init || $reset) {
         $storeVar = true;
     }
     $this->gc_id_filter = PageVar('gc_id_filter', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->gp_name = PageVar('gp_name', null, $init | $reset, false, $this->baseName, $storeVar);
     setLang(R3Locale::getLanguageCode());
     setLangInfo(array('thousands_sep' => "."));
     $this->registerAjaxFunction('getHelp');
     $this->registerAjaxFunction('countGaugeAndMonitor');
 }
Exemplo n.º 13
0
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $init = array_key_exists('init', $this->request);
     $reset = array_key_exists('reset', $this->request);
     $this->id = initVar('id');
     $this->act = initVar('act', 'list');
     $this->kind = PageVar('kind');
     $this->em_id = PageVar('em_id', null, $init | $reset, false, $this->baseName);
     $this->sl_id = PageVar('sl_id', null, $init | $reset, false, $this->baseName);
     $this->tabMode = PageVar('tab_mode', null, $init | $reset, false, $this->baseName);
     $data = R3EcoGisHelper::getMeterData($_SESSION['do_id'], $this->em_id);
     $this->fields = $this->defFields($data['em_is_production'] == 'T');
     setLang(R3Locale::getLanguageCode());
     setLangInfo(array('thousands_sep' => "."));
     $this->registerAjaxFunction('confirm_delete_consumption');
     $this->registerAjaxFunction('submitFormData');
 }
Exemplo n.º 14
0
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $this->id = initVar('id');
     $this->last_id = initVar('last_id');
     $this->file_id = initVar('file_id');
     $this->doc_object_id = initVar('doc_object_id');
     $this->type = initVar('type');
     $this->act = initVar('act', 'list');
     $this->tab_mode = initVar('tab_mode');
     $this->parent_act = PageVar('parent_act');
     $this->disposition = initVar('disposition', 'inline');
     $this->limit = 0;
     $this->fields = $this->defFields();
     $this->documentType = 'document';
     $this->isDialog = true;
     $this->registerAjaxFunction('submitFormData');
     $this->registerAjaxFunction('confirm_delete_document');
 }
Exemplo n.º 15
0
function ThumbShoeMakeThumb($pagename, $picpath, $w = 128, $h = 128)
{
    global $ThumbShoeThumbBg, $ThumbShoeThumbPrefix;
    global $UploadDir;
    $uploaddir = PageVar($pagename, '$TSAttachDir');
    $name = PageVar($pagename, '$Name');
    $thumbpath = "{$uploaddir}/{$ThumbShoeThumbPrefix}{$name}.png";
    if (!file_exists($picpath)) {
        return;
    }
    // if the thumbnail has already been created
    // and it is newer than the original image, return.
    if (file_exists($thumbpath) && filemtime($thumbpath) > filemtime($picpath)) {
        return;
    }
    if (!file_exists($uploaddir)) {
        mkdirp($uploaddir);
    }
    $bg = $ThumbShoeThumbBg;
    $tmp1 = "{$uploaddir}/{$name}_tmp.png";
    $area = $w * $h;
    # Need to use the following conversion because of
    # ImageMagick version earlier than 6.3
    $cmdfmt = 'convert -thumbnail \'%dx%d>\' -bordercolor %s -background %s -border 50 -gravity center  -crop %dx%d+0+0 +repage %s %s';
    $cl = sprintf($cmdfmt, $w, $h, $bg, $bg, $w, $h, $picpath, $tmp1);
    $r = exec($cl, $o, $status);
    if (intval($status) != 0) {
        Abort("convert returned <pre>{$r}\n" . print_r($o, true) . "'</pre> with a status '{$status}'.<br/> Command line was '{$cl}'.");
    }
    if (!file_exists($tmp1)) {
        Abort("Failed to create '{$tmp1}';<br/> Command line was '{$cl}'.");
    }
    // fluff
    $cmdfmt = 'convert -mattecolor %s -frame 6x6+3+0 %s %s';
    $cl = sprintf($cmdfmt, $bg, $tmp1, $thumbpath);
    $r = exec($cl, $o, $status);
    if (intval($status) != 0) {
        Abort("convert returned <pre>{$r}\n" . print_r($o, true) . "'</pre> with a status '{$status}'.<br/> Command line was '{$cl}'.");
    }
    unlink($tmp1);
}
Exemplo n.º 16
0
function WikiGallerySlideshow($pagename, $auth = 'read')
{
    global $WikiGallery_DefaultSlideshowDelay, $HTMLHeaderFmt, $WikiGallery_Register;
    // get delay from url
    if (isset($_GET["delay"])) {
        $delay = intval($_GET["delay"]);
    } else {
        $delay = $WikiGallery_DefaultSlideshowDelay;
    }
    // find following picture
    $group = PageVar($pagename, '$Group');
    $next = $WikiGallery_Register[$group]->neighbourPicturePage(PageVar($pagename, '$Name'), 1);
    $nextpage = "{$group}.{$next}";
    // exists?
    if ($next && PageExists($nextpage)) {
        // add refresh header
        $url = MakeLink($nextpage, $nextpage, NULL, NULL, "\$LinkUrl");
        array_unshift($HTMLHeaderFmt, "<meta http-equiv=\"refresh\" content=\"{$delay}; URL={$url}?action=slideshow&delay={$delay}\" />");
    }
    return HandleBrowse($pagename, $auth);
}
Exemplo n.º 17
0
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $this->id = initVar('id');
     $this->act = initVar('act', 'list');
     $this->tab_mode = initVar('tab_mode');
     $this->kind = initVar('kind');
     $this->ge_id = (int) initVar('ge_id');
     $this->gc_id = (int) initVar('gc_id');
     $this->limit = 0;
     $this->do_id = PageVar('do_id', $_SESSION['do_id'], false, false, $this->baseName);
     setLang(R3Locale::getLanguageCode());
     setLangInfo(array('thousands_sep' => "."));
     $this->fields = $this->defFields();
     $this->registerAjaxFunction('fetchUDM');
     $this->registerAjaxFunction('performEnergySourceRowCalc');
     $this->registerAjaxFunction('confirmDeleteGlobalConsumptionRow');
     $this->registerAjaxFunction('getEnergySource');
     $this->registerAjaxFunction('getEnergyUDM');
     $this->registerAjaxFunction('performActionCatalogCalc');
     $this->registerAjaxFunction('submitFormData');
 }
Exemplo n.º 18
0
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $this->fields = $this->defFields();
     $storeVar = isset($_GET['act']) && $_GET['act'] == 'list';
     // if true store the filter variables
     $init = array_key_exists('init', $this->request);
     $reset = array_key_exists('reset', $this->request);
     if ($init || $reset) {
         $storeVar = true;
     }
     $this->id = initVar('id');
     if (initVar('sl_id') !== null) {
         $this->id = initVar('sl_id');
     }
     $this->act = initVar('act', 'list');
     $this->last_id = initVar('last_id');
     $this->parent_act = initVar('parent_act');
     $this->do_id = $_SESSION['do_id'];
     $this->pr_id = PageVar('pr_id', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->mu_id = PageVar('mu_id', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->mu_name = PageVar('mu_name', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->st_id = PageVar('st_id', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->st_name = PageVar('st_name', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->sl_full_name = PageVar('sl_full_name', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->sl_to_check = PageVar('sl_to_check', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->order = PageVar('order', '1A', $init, false, $this->baseName, $storeVar);
     $this->pg = PageVar('pg', 0, $init | $reset, false, $this->baseName, $storeVar);
     setLang(R3Locale::getLanguageCode());
     setLangInfo(array('thousands_sep' => "."));
     $this->registerAjaxFunction('getHelp');
     $this->registerAjaxFunction('getMunicipalityList');
     $this->registerAjaxFunction('getStreetList');
     $this->registerAjaxFunction('getStreetLength');
     $this->registerAjaxFunction('confirmDeleteStreetLighting');
     $this->registerAjaxFunction('submitFormData');
 }
Exemplo n.º 19
0
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $this->fields = array();
     $init = array_key_exists('init', $this->request);
     $reset = array_key_exists('reset', $this->request);
     $this->id = initVar('id');
     $this->act = 'list';
     $this->order = PageVar('order', '1A', $init, false, $this->baseName);
     $this->pg = PageVar('pg', 0, $init | $reset, false, $this->baseName);
     $this->do_id = $_SESSION['do_id'];
     $storeVar = isset($_GET['act']) && $_GET['act'] == 'list' || $reset || $init;
     if ($init || $reset) {
         $storeVar = true;
     }
     $this->us_name_email = PageVar('us_name_email', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->us_status = PageVar('us_status', null, $init | $reset, false, $this->baseName, $storeVar);
     setLang(R3Locale::getLanguageCode());
     setLangInfo(array('thousands_sep' => "."));
     $this->registerAjaxFunction('askEnablePublicUser');
     $this->registerAjaxFunction('askDelPublicUser');
     $this->registerAjaxFunction('enablePublicUser');
     $this->registerAjaxFunction('delPublicUser');
 }
Exemplo n.º 20
0
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $this->fields = array();
     $init = array_key_exists('init', $this->request);
     $reset = array_key_exists('reset', $this->request);
     $this->id = initVar('id');
     $this->act = initVar('act', 'list');
     $this->order = PageVar('order', '1A', $init, false, $this->baseName);
     $this->pg = PageVar('pg', 0, $init | $reset, false, $this->baseName);
     $storeVar = isset($_GET['act']) && $_GET['act'] == 'list' || $reset || $init;
     // if true store the filter variables
     if ($init || $reset) {
         $storeVar = true;
     }
     $this->do_id_filter = (int) PageVar('do_id_filter', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->mu_name_collection = PageVar('mu_name_collection', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->mu_name = PageVar('mu_name', null, $init | $reset, false, $this->baseName, $storeVar);
     setLang(R3Locale::getLanguageCode());
     setLangInfo(array('thousands_sep' => "."));
     $this->registerAjaxFunction('submitFormData');
     $this->registerAjaxFunction('confirmDeleteMunicipalityCollection');
     $this->registerAjaxFunction('getAvailableMunicipalityForCollection');
 }
Exemplo n.º 21
0
function LinkPage($pagename,$imap,$path,$title,$txt,$fmt=NULL) {
  global $QueryFragPattern,$LinkPageExistsFmt,$LinkPageSelfFmt,
    $LinkPageCreateSpaceFmt,$LinkPageCreateFmt,$FmtV,$LinkTargets;
  if (!$fmt && $path{0} == '#') {
    $path = preg_replace("/[^-.:\\w]/", '', $path);
    return ($path) ? "<a href='#$path'>$txt</a>" : '';
  }
  if (!preg_match("/^\\s*([^#?]+)($QueryFragPattern)?$/",$path,$match))
    return '';
  $tgtname = MakePageName($pagename, $match[1]); 
  if (!$tgtname) return '';
  $qf = @$match[2];
  @$LinkTargets[$tgtname]++;
  if (!$fmt) {
    if (!PageExists($tgtname) && !preg_match('/[&?]action=/', $qf))
      $fmt = preg_match('/\\s/', $txt) 
             ? $LinkPageCreateSpaceFmt : $LinkPageCreateFmt;
    else
      $fmt = ($tgtname == $pagename && $qf == '') 
             ? $LinkPageSelfFmt : $LinkPageExistsFmt;
  }
  $fmt = str_replace(array('$LinkUrl', '$LinkText'),
           array(PageVar($tgtname, '$PageUrl').PUE($qf), $txt), $fmt);
  return FmtPageName($fmt,$tgtname);
}
Exemplo n.º 22
0
function PrintAttrForm($pagename) {
  global $PageAttributes, $PCache, $FmtV;
  echo FmtPageName("<form action='\$PageUrl' method='post'>
    <input type='hidden' name='action' value='postattr' />
    <input type='hidden' name='n' value='\$FullName' />
    <table>",$pagename);
  $page = $PCache[$pagename];
  foreach($PageAttributes as $attr=>$p) {
    if (!$p) continue;
    if (strncmp($attr, 'passwd', 6) == 0) {
      $setting = PageVar($pagename, '$Passwd'.ucfirst(substr($attr, 6)));
      $value = '';
    } else { $setting = $value = PHSC(@$page[$attr]); }
    $prompt = FmtPageName($p,$pagename);
    echo "<tr><td>$prompt</td>
      <td><input type='text' name='$attr' value='$value' /></td>
      <td>$setting</td></tr>";
  }
  echo FmtPageName("</table><input type='submit' value='$[Save]' /></form>",
         $pagename);
}
Exemplo n.º 23
0
function LinkPage($pagename, $imap, $path, $title, $txt, $fmt = NULL)
{
    global $QueryFragPattern, $LinkPageExistsFmt, $LinkPageSelfFmt, $LinkPageCreateSpaceFmt, $LinkPageCreateFmt, $FmtV, $LinkTargets;
    if (!$fmt && $path[0] == '#') {
        $path = preg_replace("/[^-.:\\w]/", '', $path);
        return "<a href='#{$path}'>{$txt}</a>";
    }
    if (!preg_match("/^([^#?]+)({$QueryFragPattern})?\$/", $path, $match)) {
        return '';
    }
    $tgtname = MakePageName($pagename, $match[1]);
    $qf = @$match[2];
    @$LinkTargets[$tgtname]++;
    if (!$fmt) {
        if (PageExists($tgtname)) {
            $fmt = $tgtname == $pagename && $qf == '' ? $LinkPageSelfFmt : $LinkPageExistsFmt;
        } elseif (preg_match('/\\s/', $txt)) {
            $fmt = $LinkPageCreateSpaceFmt;
        } else {
            $fmt = $LinkPageCreateFmt;
        }
    }
    $fmt = str_replace(array('$LinkUrl', '$LinkText'), array(PageVar($tgtname, '$PageUrl') . PUE($qf), $txt), $fmt);
    return FmtPageName($fmt, $tgtname);
}
Exemplo n.º 24
0
function FPLTemplateFormat($pagename, $matches, $opt, $tparts, &$output){
  global $Cursor, $FPLTemplateMarkupFunction;
  SDV($FPLTemplateMarkupFunction, 'MarkupToHTML');
  $savecursor = $Cursor;
  $pagecount = 0; $groupcount = 0; $grouppagecount = 0;
  $pseudovars = array('{$$PageCount}' => &$pagecount, 
                      '{$$GroupCount}' => &$groupcount, 
                      '{$$GroupPageCount}' => &$grouppagecount);

  foreach(preg_grep('/^[\\w$]/', array_keys($opt)) as $k) 
    if (!is_array($opt[$k]))
      $pseudovars["{\$\$$k}"] = htmlspecialchars($opt[$k], ENT_NOQUOTES);

  $vk = array_keys($pseudovars);
  $vv = array_values($pseudovars);

  $lgroup = ''; $out = '';
  if(count($matches)==0 )
  {
    $t = 0;
    while($t < count($tparts))
    {
      if($tparts[$t]=='template' && $tparts[$t+2]=='none')
      {
         $out .= MarkupRestore( FPLExpandItemVars($tparts[$t+4], $matches, 0, $pseudovars));
         $t+=4;
      }
      $t++;
    }
  } # else:
  foreach($matches as $i => $pn) {
    $group = PageVar($pn, '$Group');
    if ($group != $lgroup) { $groupcount++; $grouppagecount = 0; $lgroup = $group; }
    $grouppagecount++; $pagecount++;

    $t = 0;
    while ($t < count($tparts)) {
      if ($tparts[$t] != 'template') { $item = $tparts[$t]; $t++; }
      else {
        list($neg, $when, $control, $item) = array_slice($tparts, $t+1, 4); $t+=5;
        if($when=='none') continue;
        if (!$control) {
          if ($when == 'first' && ($neg xor ($i != 0))) continue;
          if ($when == 'last' && ($neg xor ($i != count($matches) - 1))) continue;
        } else {
          if ($when == 'first' || !isset($last[$t])) {
            $curr = FPLExpandItemVars($control, $matches, $i, $pseudovars);
            if ($when == 'first' && ($neg xor (($i != 0) && ($last[$t] == $curr))))
              { $last[$t] = $curr; continue; }
            $last[$t] = $curr;
          }
          if ($when == 'last') {
            $next = FPLExpandItemVars($control, $matches, $i+1, $pseudovars);
            if ($neg xor ($next == $last[$t] && $i != count($matches) - 1)) continue;
            $last[$t] = $next;
          }
        }
      }
      $item = FPLExpandItemVars($item, $matches, $i, $pseudovars);
      $out .= MarkupRestore($item);
    }
  }

  $class = preg_replace('/[^-a-zA-Z0-9\\x80-\\xff]/', ' ', @$opt['class']);
  if ($class) $class = " class='$class'";
  $wrap = @$opt['wrap'];
  if ($wrap != 'inline') {
    $out = $FPLTemplateMarkupFunction($pagename, $out, array('escape' => 0, 'redirect'=>1));
    if ($wrap != 'none') $out = "<div$class>$out</div>";
  }
  $Cursor = $savecursor;
  $output .= $out;
}
Exemplo n.º 25
0
function FPLTemplate($pagename, &$matches, $opt)
{
    global $Cursor, $FPLTemplatePageFmt, $RASPageName, $PageListArgPattern;
    SDV($FPLTemplatePageFmt, array('{$FullName}', '{$SiteGroup}.LocalTemplates', '{$SiteGroup}.PageListTemplates'));
    StopWatch("FPLTemplate begin");
    $template = @$opt['template'];
    if (!$template) {
        $template = @$opt['fmt'];
    }
    $ttext = RetrieveAuthSection($pagename, $template, $FPLTemplatePageFmt);
    $ttext = PVSE(Qualify($RASPageName, $ttext));
    ##  save any escapes
    $ttext = MarkupEscape($ttext);
    ##  remove any anchor markups to avoid duplications
    $ttext = preg_replace('/\\[\\[#[A-Za-z][-.:\\w]*\\]\\]/', '', $ttext);
    ##  extract portions of template
    $tparts = preg_split('/\\(:(template)\\s+(\\w+)\\s*(.*?):\\)/i', $ttext, -1, PREG_SPLIT_DELIM_CAPTURE);
    ##  handle (:template defaults:)
    $i = 0;
    while ($i < count($tparts)) {
        if ($tparts[$i] != 'template') {
            $i++;
            continue;
        }
        if ($tparts[$i + 1] != 'defaults' && $tparts[$i + 1] != 'default') {
            $i += 4;
            continue;
        }
        $opt = array_merge(ParseArgs($tparts[$i + 2], $PageListArgPattern), $opt);
        array_splice($tparts, $i, 3);
    }
    SDVA($opt, array('class' => 'fpltemplate', 'wrap' => 'div'));
    ##  get the list of pages
    $matches = array_values(MakePageList($pagename, $opt, 0));
    ##  extract page subset according to 'count=' parameter
    if (@$opt['count']) {
        list($r0, $r1) = CalcRange($opt['count'], count($matches));
        if ($r1 < $r0) {
            $matches = array_reverse(array_slice($matches, $r1 - 1, $r0 - $r1 + 1));
        } else {
            $matches = array_slice($matches, $r0 - 1, $r1 - $r0 + 1);
        }
    }
    $savecursor = $Cursor;
    $pagecount = 0;
    $groupcount = 0;
    $grouppagecount = 0;
    $pseudovars = array('{$$PageCount}' => &$pagecount, '{$$GroupCount}' => &$groupcount, '{$$GroupPageCount}' => &$grouppagecount);
    foreach (preg_grep('/^[\\w$]/', array_keys($opt)) as $k) {
        if (!is_array($opt[$k])) {
            $pseudovars["{\$\${$k}}"] = htmlspecialchars($opt[$k], ENT_NOQUOTES);
        }
    }
    $vk = array_keys($pseudovars);
    $vv = array_values($pseudovars);
    $lgroup = '';
    $out = '';
    foreach ($matches as $i => $pn) {
        $group = PageVar($pn, '$Group');
        if ($group != $lgroup) {
            $groupcount++;
            $grouppagecount = 0;
            $lgroup = $group;
        }
        $grouppagecount++;
        $pagecount++;
        $t = 0;
        while ($t < count($tparts)) {
            if ($tparts[$t] != 'template') {
                $item = $tparts[$t];
                $t++;
            } else {
                list($when, $control, $item) = array_slice($tparts, $t + 1, 3);
                $t += 4;
                if (!$control) {
                    if ($when == 'first' && $i != 0) {
                        continue;
                    }
                    if ($when == 'last' && $i != count($matches) - 1) {
                        continue;
                    }
                } else {
                    if ($when == 'first' || !isset($last[$t])) {
                        $Cursor['<'] = $Cursor['&lt;'] = (string) @$matches[$i - 1];
                        $Cursor['='] = $pn;
                        $Cursor['>'] = $Cursor['&gt;'] = (string) @$matches[$i + 1];
                        $curr = str_replace($vk, $vv, $control);
                        $curr = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PageVar(\$pn, '\$2', '\$1')", $curr);
                        if ($when == 'first' && $i > 0 && $last[$t] == $curr) {
                            continue;
                        }
                        $last[$t] = $curr;
                    }
                    if ($when == 'last') {
                        $Cursor['<'] = $Cursor['&lt;'] = $pn;
                        $Cursor['='] = (string) @$matches[$i + 1];
                        $Cursor['>'] = $Cursor['&gt;'] = (string) @$matches[$i + 2];
                        $next = str_replace($vk, $vv, $control);
                        $next = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PageVar(\$pn, '\$2', '\$1')", $next);
                        if ($next == $last[$t] && $i != count($matches) - 1) {
                            continue;
                        }
                        $last[$t] = $next;
                    }
                }
            }
            $Cursor['<'] = $Cursor['&lt;'] = (string) @$matches[$i - 1];
            $Cursor['='] = $pn;
            $Cursor['>'] = $Cursor['&gt;'] = (string) @$matches[$i + 1];
            $item = str_replace($vk, $vv, $item);
            $item = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PVSE(PageVar(\$pn, '\$2', '\$1'))", $item);
            $out .= MarkupRestore($item);
        }
    }
    $class = preg_replace('/[^-a-zA-Z0-9\\x80-\\xff]/', ' ', @$opt['class']);
    if ($class) {
        $class = " class='{$class}'";
    }
    $wrap = @$opt['wrap'];
    if ($wrap != 'inline') {
        $out = MarkupToHTML($pagename, $out, array('escape' => 0, 'redirect' => 1));
        if ($wrap != 'none') {
            $out = "<div{$class}>{$out}</div>";
        }
    }
    $Cursor = $savecursor;
    StopWatch("FPLTemplate end");
    return $out;
}
Exemplo n.º 26
0
 public function getListData($request)
 {
     $db = ezcDbInstance::get();
     $sql = $this->getListSQL();
     // Crea la tabella per poter chiamare createListTableHeader
     $this->createListTable();
     $this->createListTableHeader($this->order);
     $init = array_key_exists('init', $this->request) || array_key_exists('reset', $this->request);
     if (!isset($this->limit)) {
         $this->limit = $this->auth === null ? 10 : max(10, $this->auth->getConfigValue('SETTINGS', 'ROW_COUNT', 10));
     }
     if (!isset($this->pg)) {
         $this->pg = PageVar('pg', 1, $init);
     }
     // Apply the SQL order
     if ($this->order != '') {
         $orderFields = $this->simpleTable->getSQLOrder($this->order);
         if ($orderFields != '') {
             $sql .= " ORDER BY " . $this->simpleTable->getSQLOrder($this->order);
         }
     }
     if ($this->limit > 0) {
         $sql .= " LIMIT " . (int) max(0, $this->limit);
         $sql .= " OFFSET " . (int) max(0, ($this->pg - 1) * $this->limit);
     }
     $rows = array();
     $stmt = $db->query($sql);
     $rowNo = 0;
     while ($row = $stmt->fetch()) {
         $rowNo++;
         $data = array();
         foreach ($this->simpleTable->getFields() as $field) {
             $links = $this->getListTableRowOperations($row);
             if ($field['type'] == 'LINK') {
                 $data[] = $this->simpleTable->CreateLinksCell($links);
             } else {
                 if ($field['type'] == 'CALCULATED') {
                     $data[] = $this->simpleTable->getCalcValue($field['field']);
                 } else {
                     $value = $row[$field['field']];
                     $format = $field['format'];
                     $number_format = $field['number_format'];
                     // Corregge il campo data
                     if ($field['type'] == 'DATE') {
                         if ($value == '0000-00-00') {
                             $value = '';
                         } else {
                             $value = SQLDateToStr($value, $format === false ? 'd/m/Y' : $format);
                         }
                     } else {
                         if ($field['type'] == 'TIME') {
                             if ($value == '00:00:00') {
                                 $value = '';
                             } else {
                                 $value = SQLDateToStr($value, $format === false ? 'h:i:s' : $format);
                             }
                         } else {
                             if ($field['type'] == 'DATETIME') {
                                 if ($value == '0000-00-00 00:00:00') {
                                     $value = '';
                                 } else {
                                     $value = SQLDateToStr($value, $format === false ? 'd/m/Y H:i:s' : $format);
                                 }
                             } else {
                                 if (strpos($field['type'], 'URL') !== false) {
                                     if (strpos($field['type'], 'MAILTO') !== false) {
                                         $value = sprintf("<a href=\"mailto:%s\">%s</a>", $value, $value);
                                     } else {
                                         $value = sprintf("<a href=\"%s\" target=\"_BLANK\">%s</a>", $value, $value);
                                     }
                                 } else {
                                     // Format or number_format
                                     if ($value != '') {
                                         if ($format !== false) {
                                             $value = sprintf($format, $value);
                                         } else {
                                             if ($number_format !== false) {
                                                 if (!defined("__R3_LOCALE__")) {
                                                     require_once 'r3locale.php';
                                                 }
                                                 $localeInfo = getLocaleInfo();
                                                 if (!is_array($number_format)) {
                                                     $number_format = array('decimals' => $number_format, 'dec_point' => $localeInfo['decimal_point'], 'thousands_sep' => $localeInfo['thousands_sep']);
                                                 } else {
                                                     $number_format = array_merge(array('decimals' => 0, 'dec_point' => $localeInfo['decimal_point'], 'thousands_sep' => $localeInfo['thousands_sep']), $number_format);
                                                 }
                                                 if ($number_format['decimals'] === null && is_numeric($value)) {
                                                     $diff = round($value - (int) $value, 10);
                                                     if ($diff == 0) {
                                                         $number_format['decimals'] = 0;
                                                     } else {
                                                         $number_format['decimals'] = strlen($diff) - 2;
                                                         // -2 is 0. of the number
                                                     }
                                                 }
                                                 $value = number_format($value, $number_format['decimals'], $number_format['dec_point'], $number_format['thousands_sep']);
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     $data[] = $value;
                 }
             }
         }
         $rows[] = array('id' => $rowNo, 'cell' => $data);
     }
     $result = array();
     $tot = $db->query($this->getListTotSQL())->fetchColumn();
     $result['total'] = ceil($tot / $this->limit);
     $result['page'] = $this->pg;
     $result['records'] = $tot;
     $result['rows'] = $rows;
     return $result;
 }
Exemplo n.º 27
0
 public function __construct(array $request = array(), array $opt = array())
 {
     parent::__construct($request, $opt);
     $this->fields = $this->defFields();
     $storeVar = isset($_GET['act']) && $_GET['act'] == 'list';
     // if true store the filter variables
     $init = array_key_exists('init', $this->request);
     $reset = array_key_exists('reset', $this->request);
     if ($init || $reset) {
         $storeVar = true;
     }
     $this->id = (int) initVar('id');
     $this->last_id = initVar('last_id');
     $this->act = initVar('act', 'list');
     $this->parent_act = initVar('parent_act');
     $this->do_id = PageVar('do_id', $_SESSION['do_id'], $init | $reset, false, $this->baseName, $storeVar);
     $this->pr_id = PageVar('pr_id', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->mu_id = PageVar('mu_id', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->mu_name = PageVar('mu_name', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->gst_name = PageVar('gst_name', null, $init | $reset, false, $this->baseName, $storeVar);
     $this->order = PageVar('order', '1A', $init, false, $this->baseName, $storeVar);
     $this->pg = PageVar('pg', 0, $init | $reset, false, $this->baseName, $storeVar);
     setLang(R3Locale::getLanguageCode());
     setLangInfo(array('thousands_sep' => "."));
     $this->registerAjaxFunction('getHelp');
     $this->registerAjaxFunction('loadGE_GS');
     $this->registerAjaxFunction('submitFormData');
     $this->registerAjaxFunction('exportPAES');
     $this->registerAjaxFunction('exportPAESDlg');
     $this->registerAjaxFunction('getExportPAESStatus');
     $this->registerAjaxFunction('askDelGlobalStrategy');
 }
Exemplo n.º 28
0
function FPLTemplateFormat($pagename, $matches, $opt, $tparts, &$output)
{
    global $Cursor, $FPLTemplateMarkupFunction;
    SDV($FPLTemplateMarkupFunction, 'MarkupToHTML');
    $savecursor = $Cursor;
    $pagecount = 0;
    $groupcount = 0;
    $grouppagecount = 0;
    $pseudovars = array('{$$PageCount}' => &$pagecount, '{$$GroupCount}' => &$groupcount, '{$$GroupPageCount}' => &$grouppagecount);
    foreach (preg_grep('/^[\\w$]/', array_keys($opt)) as $k) {
        if (!is_array($opt[$k])) {
            $pseudovars["{\$\${$k}}"] = htmlspecialchars($opt[$k], ENT_NOQUOTES);
        }
    }
    $vk = array_keys($pseudovars);
    $vv = array_values($pseudovars);
    $lgroup = '';
    $out = '';
    if (count($matches) == 0) {
        $t = 0;
        while ($t < count($tparts)) {
            if ($tparts[$t] == 'template' && $tparts[$t + 1] == 'none') {
                $out .= MarkupRestore($tparts[$t + 3]);
                $t += 3;
            }
            $t++;
        }
    }
    # else:
    foreach ($matches as $i => $pn) {
        $group = PageVar($pn, '$Group');
        if ($group != $lgroup) {
            $groupcount++;
            $grouppagecount = 0;
            $lgroup = $group;
        }
        $grouppagecount++;
        $pagecount++;
        $t = 0;
        while ($t < count($tparts)) {
            if ($tparts[$t] != 'template') {
                $item = $tparts[$t];
                $t++;
            } else {
                list($when, $control, $item) = array_slice($tparts, $t + 1, 3);
                $t += 4;
                if ($when == 'none') {
                    continue;
                }
                if (!$control) {
                    if ($when == 'first' && $i != 0) {
                        continue;
                    }
                    if ($when == 'last' && $i != count($matches) - 1) {
                        continue;
                    }
                } else {
                    if ($when == 'first' || !isset($last[$t])) {
                        $Cursor['<'] = $Cursor['&lt;'] = (string) @$matches[$i - 1];
                        $Cursor['='] = $pn;
                        $Cursor['>'] = $Cursor['&gt;'] = (string) @$matches[$i + 1];
                        $curr = str_replace($vk, $vv, $control);
                        $curr = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PageVar(\$pn, '\$2', '\$1')", $curr);
                        if ($when == 'first' && $i > 0 && $last[$t] == $curr) {
                            continue;
                        }
                        $last[$t] = $curr;
                    }
                    if ($when == 'last') {
                        $Cursor['<'] = $Cursor['&lt;'] = $pn;
                        $Cursor['='] = (string) @$matches[$i + 1];
                        $Cursor['>'] = $Cursor['&gt;'] = (string) @$matches[$i + 2];
                        $next = str_replace($vk, $vv, $control);
                        $next = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PageVar(\$pn, '\$2', '\$1')", $next);
                        if ($next == $last[$t] && $i != count($matches) - 1) {
                            continue;
                        }
                        $last[$t] = $next;
                    }
                }
            }
            $Cursor['<'] = $Cursor['&lt;'] = (string) @$matches[$i - 1];
            $Cursor['='] = $pn;
            $Cursor['>'] = $Cursor['&gt;'] = (string) @$matches[$i + 1];
            $item = str_replace($vk, $vv, $item);
            $item = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PVSE(PageVar(\$pn, '\$2', '\$1'))", $item);
            $out .= MarkupRestore($item);
        }
    }
    $class = preg_replace('/[^-a-zA-Z0-9\\x80-\\xff]/', ' ', @$opt['class']);
    if ($class) {
        $class = " class='{$class}'";
    }
    $wrap = @$opt['wrap'];
    if ($wrap != 'inline') {
        $out = $FPLTemplateMarkupFunction($pagename, $out, array('escape' => 0, 'redirect' => 1));
        if ($wrap != 'none') {
            $out = "<div{$class}>{$out}</div>";
        }
    }
    $Cursor = $savecursor;
    $output .= $out;
}
Exemplo n.º 29
0
function LinkPage($pagename, $imap, $path, $title, $txt, $fmt = NULL)
{
    global $QueryFragPattern, $LinkPageExistsFmt, $LinkPageSelfFmt, $LinkPageCreateSpaceFmt, $LinkPageCreateFmt, $LinkTargets, $EnableLinkPageRelative;
    if (!$fmt && $path[0] == '#') {
        $path = preg_replace("/[^-.:\\w]/", '', $path);
        return $path ? "<a href='#{$path}'>{$txt}</a>" : '';
    }
    if (!preg_match("/^\\s*([^#?]+)({$QueryFragPattern})?\$/", $path, $match)) {
        return '';
    }
    $tgtname = MakePageName($pagename, $match[1]);
    if (!$tgtname) {
        return '';
    }
    $qf = @$match[2];
    @$LinkTargets[$tgtname]++;
    if (!$fmt) {
        if (!PageExists($tgtname) && !preg_match('/[&?]action=/', $qf)) {
            $fmt = preg_match('/\\s/', $txt) ? $LinkPageCreateSpaceFmt : $LinkPageCreateFmt;
        } else {
            $fmt = $tgtname == $pagename && $qf == '' ? $LinkPageSelfFmt : $LinkPageExistsFmt;
        }
    }
    $url = PageVar($tgtname, '$PageUrl');
    if (@$EnableLinkPageRelative) {
        $url = preg_replace('!^[a-z]+://[^/]*!i', '', $url);
    }
    $fmt = str_replace(array('$LinkUrl', '$LinkText'), array($url . PUE($qf), $txt), $fmt);
    return FmtPageName($fmt, $tgtname);
}
Exemplo n.º 30
0
function FPLTemplate($pagename, &$matches, $opt)
{
    global $Cursor, $FPLFormatOpt, $FPLTemplatePageFmt;
    SDV($FPLTemplatePageFmt, array('{$FullName}', '{$SiteGroup}.LocalTemplates', '{$SiteGroup}.PageListTemplates'));
    $template = @$opt['template'];
    if (!$template) {
        $template = @$opt['fmt'];
    }
    list($tname, $qf) = explode('#', $template, 2);
    if ($tname) {
        $tname = array(MakePageName($pagename, $tname));
    } else {
        $tname = (array) $FPLTemplatePageFmt;
    }
    foreach ($tname as $t) {
        $t = FmtPageName($t, $pagename);
        if (!PageExists($t)) {
            continue;
        }
        if ($qf) {
            $t .= "#{$qf}";
        }
        $ttext = IncludeText($pagename, $t, true);
        if (!$qf || strpos($ttext, "[[#{$qf}]]") !== false) {
            break;
        }
    }
    ##   remove any anchor markups to avoid duplications
    $ttext = preg_replace('/\\[\\[#[A-Za-z][-.:\\w]*\\]\\]/', '', $ttext);
    if (!@$opt['order'] && !@$opt['trail']) {
        $opt['order'] = 'name';
    }
    $matches = array_values(MakePageList($pagename, $opt, 0));
    if (@$opt['count']) {
        array_splice($matches, $opt['count']);
    }
    $savecursor = $Cursor;
    $pagecount = 0;
    $groupcount = 0;
    $grouppagecount = 0;
    $vk = array('{$PageCount}', '{$GroupCount}', '{$GroupPageCount}');
    $vv = array(&$pagecount, &$groupcount, &$grouppagecount);
    $lgroup = '';
    $out = '';
    foreach ($matches as $i => $pn) {
        $prev = (string) @$matches[$i - 1];
        $next = (string) @$matches[$i + 1];
        $Cursor['<'] = $Cursor['&lt;'] = $prev;
        $Cursor['='] = $pn;
        $Cursor['>'] = $Cursor['&gt;'] = $next;
        $group = PageVar($pn, '$Group');
        if ($group != $lgroup) {
            $groupcount++;
            $grouppagecount = 0;
        }
        $grouppagecount++;
        $pagecount++;
        $item = str_replace($vk, $vv, $ttext);
        $item = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PageVar(\$pn, '\$2', '\$1')", $item);
        $out .= $item;
        $lgroup = $group;
    }
    $class = preg_replace('/[^-a-zA-Z0-9\\x80-\\xff]/', ' ', @$opt['class']);
    $div = $class ? "<div class='{$class}'>" : '<div>';
    return $div . MarkupToHTML($pagename, $out, array('escape' => 0)) . '</div>';
}