public function GetPageList()
 {
     $currentPageCaption = $this->GetShortCaption();
     $result = new PageList($this);
     $result->AddGroup($this->RenderText('Default'));
     if (GetCurrentUserGrantForDataSource('dbo.EtatConnexion')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Dbo.EtatConnexion'), 'dbo.EtatConnexion.php', $this->RenderText('Dbo.EtatConnexion'), $currentPageCaption == $this->RenderText('Dbo.EtatConnexion'), false, $this->RenderText('Default')));
     }
     if (GetCurrentUserGrantForDataSource('dbo.EvenementSysteme')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Dbo.EvenementSysteme'), 'dbo.EvenementSysteme.php', $this->RenderText('Dbo.EvenementSysteme'), $currentPageCaption == $this->RenderText('Dbo.EvenementSysteme'), false, $this->RenderText('Default')));
     }
     if (GetCurrentUserGrantForDataSource('dbo.InfosFichiers')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Dbo.InfosFichiers'), 'dbo.InfosFichiers.php', $this->RenderText('Dbo.InfosFichiers'), $currentPageCaption == $this->RenderText('Dbo.InfosFichiers'), false, $this->RenderText('Default')));
     }
     if (GetCurrentUserGrantForDataSource('dbo.IPClients')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Dbo.IPClients'), 'dbo.IPClients.php', $this->RenderText('Dbo.IPClients'), $currentPageCaption == $this->RenderText('Dbo.IPClients'), false, $this->RenderText('Default')));
     }
     if (GetCurrentUserGrantForDataSource('dbo.MachinesClientes')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Dbo.MachinesClientes'), 'dbo.MachinesClientes.php', $this->RenderText('Dbo.MachinesClientes'), $currentPageCaption == $this->RenderText('Dbo.MachinesClientes'), false, $this->RenderText('Default')));
     }
     if (HasAdminPage() && GetApplication()->HasAdminGrantForCurrentUser()) {
         $result->AddGroup('Admin area');
         $result->AddPage(new PageLink($this->GetLocalizerCaptions()->GetMessageString('AdminPage'), 'phpgen_admin.php', $this->GetLocalizerCaptions()->GetMessageString('AdminPage'), false, false, 'Admin area'));
     }
     return $result;
 }
 function populate()
 {
     $tickets = new TicketCollection(new Ticket());
     $pl = new PageList('current_tickets');
     $ticket_sh = new SearchHandler($tickets, false);
     $ticket_sh->setLimit(10);
     $ticket_sh->setOrderBy('created', 'ASC');
     $user = new User();
     $user->loadBy('username', EGS_USERNAME);
     $ticket_sh->addConstraint(new Constraint('originator_person_id', '=', $user->username));
     $ticket_sh->addConstraint(new Constraint('usercompanyid', '=', EGS_COMPANY_ID));
     // Find open statuses
     $statuses = new TicketStatusCollection(new TicketStatus());
     $status_sh = new SearchHandler($statuses);
     $status_sh->addConstraint(new Constraint('usercompanyid', '=', EGS_COMPANY_ID));
     $status_sh->addConstraint(new Constraint('status_code', '=', 'NEW'), 'OR');
     $status_sh->addConstraint(new Constraint('status_code', '=', 'OPEN'), 'OR');
     $statuses->load($status_sh);
     foreach ($statuses->getContents() as $status) {
         $ticket_sh->addConstraint(new Constraint('client_ticket_status_id', '=', $status->id), 'OR');
     }
     $tickets->load($ticket_sh);
     $pl->addFromCollection($tickets, array('module' => 'ticketing', 'controller' => 'tickets', 'action' => 'view'), array('id'), 'ticket', 'summary');
     $this->contents = $pl->getPages()->toArray();
 }
 public function run()
 {
     $cfg = new Config();
     $pNum = (int) $cfg->get('OLD_VERSION_JOB_PAGE_NUM');
     $pNum = $pNum < 0 ? 1 : $pNum + 1;
     $pl = new PageList();
     $pl->setItemsPerPage(3);
     /* probably want to keep a record of pages that have been gone through 
      * so you don't start from the beginning each time..
      */
     $pages = $pl->getPage($pNum);
     if (!count($pages)) {
         $cfg->save('OLD_VERSION_JOB_PAGE_NUM', 0);
         return t("All pages have been processed, starting from beginning on next run.");
     }
     $versionCount = 0;
     $pagesAffected = array();
     foreach ($pages as $page) {
         if ($page instanceof Page) {
             $pvl = new VersionList($page);
             $pagesAffected[] = $page->getCollectionID();
             foreach (array_slice(array_reverse($pvl->getVersionListArray()), 10) as $v) {
                 if ($v instanceof CollectionVersion && !$v->isApproved() && !$v->isMostRecent()) {
                     @$v->delete();
                     $versionCount++;
                 }
             }
         }
     }
     $pageCount = count($pagesAffected);
     $cfg->save('OLD_VERSION_JOB_PAGE_NUM', $pNum);
     //i18n: %1$d is the number of versions deleted, %2$d is the number of affected pages, %3$d is the number of times that the Remove Old Page Versions job has been executed.
     return t2('%1$d versions deleted from %2$d page (%3$d)', '%1$d versions deleted from %2$d pages (%3$s)', $pageCount, $versionCount, $pageCount, implode(',', $pagesAffected));
 }
 public function GetPageList()
 {
     $currentPageCaption = $this->GetShortCaption();
     $result = new PageList($this);
     if (GetCurrentUserGrantForDataSource('public.office_holder')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Office Holders'), 'public.office_holder.php', $this->RenderText('Office Holders'), $currentPageCaption == $this->RenderText('Office Holders')));
     }
     if (GetCurrentUserGrantForDataSource('public.office')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Political Offices'), 'public.office.php', $this->RenderText('Political Offices'), $currentPageCaption == $this->RenderText('Political Offices')));
     }
     if (GetCurrentUserGrantForDataSource('public.office_docs')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Political Office Filing Documents'), 'public.office_docs.php', $this->RenderText('Political Office Filing Documents'), $currentPageCaption == $this->RenderText('Political Office Filing Documents')));
     }
     if (GetCurrentUserGrantForDataSource('public.election_div')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Election Divisions'), 'public.election_div.php', $this->RenderText('Election Divisions'), $currentPageCaption == $this->RenderText('Election Divisions')));
     }
     if (GetCurrentUserGrantForDataSource('public.election_div_docs')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Election Division Filing Documents'), 'public.election_div_docs.php', $this->RenderText('Election Division Filing Documents'), $currentPageCaption == $this->RenderText('Election Division Filing Documents')));
     }
     if (GetCurrentUserGrantForDataSource('public.district')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Political Districts'), 'public.district.php', $this->RenderText('Political Districts'), $currentPageCaption == $this->RenderText('Political Districts')));
     }
     if (GetCurrentUserGrantForDataSource('public.office_position')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Political Office Positions'), 'public.office_position.php', $this->RenderText('Political Office Positions'), $currentPageCaption == $this->RenderText('Political Office Positions')));
     }
     if (HasAdminPage() && GetApplication()->HasAdminGrantForCurrentUser()) {
         $result->AddPage(new PageLink($this->GetLocalizerCaptions()->GetMessageString('AdminPage'), 'phpgen_admin.php', $this->GetLocalizerCaptions()->GetMessageString('AdminPage'), false, true));
     }
     return $result;
 }
 public function form()
 {
     Loader::model('page_list');
     $pl = new PageList();
     $lastParent = '';
     $selected = $_REQUEST['akID'][$this->getAttributeKey()->getAttributeKeyID()]['value'];
     if (!$selected && $this->getAttributeValueID() > 0) {
         $selected = $this->getValue()->cID;
     }
     $selectString = "<select id='{$this->field('value')}' name='{$this->field('value')}' ><option value=''>--</option>";
     $pl->filterByCollectionTypeHandle('city');
     $pages = $pl->get();
     uasort($pages, function ($a, $b) {
         $ap = $a->getCollectionParentID();
         $bp = $b->getCollectionParentID();
         return $ap === $bp ? 0 : strcmp(Page::getByID($ap)->getCollectionName(), Page::getByID($bp)->getCollectionName());
     });
     foreach ($pages as $page) {
         $parent = Page::getByID($page->getCollectionParentID())->getCollectionName();
         if ($lastParent != $parent) {
             if ($lastParent !== '') {
                 $selectString .= '</optgroup>';
             }
             $selectString .= "<optgroup label='{$parent}'>";
             $lastParent = $parent;
         }
         $selectedAttributeVal = '';
         if ($selected === $page->cID) {
             $selectedAttributeVal = ' selected="selected"';
         }
         $selectString .= "<option value=\"{$page->getCollectionID()}\"" . $selectedAttributeVal . ">{$page->getCollectionName()}</option>";
     }
     $selectString .= '</select>';
     echo $selectString;
 }
Exemple #6
0
 public function view()
 {
     parent::view();
     $bg = $this->city->fullbg;
     if ($bg) {
         $this->bodyData['bg'] = $bg->getURL();
     }
     $this->bodyData['classes'][] = 'city-page';
     $this->bodyData['pageViewName'] = 'CityPageView';
     $this->set('bodyData', $this->bodyData);
     $this->set('pageType', 'city-page');
     $this->set('isCityOrganizer', (new User())->getUserID() === $this->city->cityOrganizer->getUserID());
     $this->set('isLoggedIn', (bool) Loader::helper('concrete/dashboard')->canRead());
     $this->set('isCampaignActive', false);
     // Is the donations campaign running?
     $this->set('canEdit', is_object(ComposerPage::getByID($this->c->getCollectionID())));
     $this->set('city', $this->city);
     // Make JSON available
     $this->addToJanesWalk(['city' => $this->city]);
     // Are there blog entries for this city?
     $blog = new PageList();
     $blog->filterByCollectionTypeHandle('city_blog');
     $blog->filterByParentID($this->c->getCollectionID());
     $this->set('blog', $blog->get(1)[0]);
 }
 public function run()
 {
     $js = Loader::helper('json');
     $pl = new PageList();
     $pl->filterByCollectionTypeHandle('city');
     $pages = $pl->get();
     $updated = 0;
     $not = 0;
     echo "Loading city coordinates.. \n";
     foreach ($pages as $page) {
         if (!trim($page->getAttribute('latlng')) || trim($page->getAttribute('latlng')) === ',') {
             $parent = Page::getByID($page->getCollectionParentID());
             $city = "{$page->getCollectionName()}, {$parent->getCollectionName()}";
             $cityLocation = file_get_contents("https://maps.google.com/maps/api/geocode/json?address=" . urlencode($city) . "&sensor=false&key=AIzaSyAvsH_wiFHJCuMPPuVifJ7QgaRCStKTdZM");
             $responseObj = $js->decode($cityLocation);
             if ($responseObj->status != 'ZERO_RESULTS') {
                 $page->setAttribute('latlng', $responseObj->results[0]->geometry->location->lat . "," . $responseObj->results[0]->geometry->location->lng);
                 $updated++;
             } else {
                 $not++;
             }
         }
     }
     return t("{$updated} cities geocoded, {$not} cities failed lookup.");
 }
Exemple #8
0
 public function GetPageList()
 {
     $currentPageCaption = $this->GetShortCaption();
     $result = new PageList($this);
     $result->AddGroup($this->RenderText('Maestras'));
     $result->AddGroup($this->RenderText('Paramétricas'));
     if (GetCurrentUserGrantForDataSource('public.sga_accion')->HasViewGrant())
         $result->AddPage(new PageLink($this->RenderText('Acción (Espacio / Bien)'), 'accion.php', $this->RenderText('Acción'), $currentPageCaption == $this->RenderText('Acción (Espacio / Bien)'), false, $this->RenderText('Maestras')));
     if (GetCurrentUserGrantForDataSource('public.sga_tarea_plan')->HasViewGrant())
         $result->AddPage(new PageLink($this->RenderText('Tarea Planificada'), 'tarea_plan.php', $this->RenderText('Tarea Planificada'), $currentPageCaption == $this->RenderText('Tarea Planificada'), false, $this->RenderText('Maestras')));
     if (GetCurrentUserGrantForDataSource('public.sga_espacio')->HasViewGrant())
         $result->AddPage(new PageLink($this->RenderText('Espacio'), 'espacio.php', $this->RenderText('Espacio'), $currentPageCaption == $this->RenderText('Espacio'), false, $this->RenderText('Maestras')));
     if (GetCurrentUserGrantForDataSource('public.sga_bien')->HasViewGrant())
         $result->AddPage(new PageLink($this->RenderText('Bien'), 'bien.php', $this->RenderText('Bien'), $currentPageCaption == $this->RenderText('Bien'), false, $this->RenderText('Maestras')));
     if (GetCurrentUserGrantForDataSource('public.sga_metodologia')->HasViewGrant())
         $result->AddPage(new PageLink($this->RenderText('Metodologia de Acción'), 'metodologia.php', $this->RenderText('Metodologia'), $currentPageCaption == $this->RenderText('Metodologia de Acción'), false, $this->RenderText('Paramétricas')));
     if (GetCurrentUserGrantForDataSource('public.sga_tipo_accion')->HasViewGrant())
         $result->AddPage(new PageLink($this->RenderText('Tipo Accion'), 'tipo_accion.php', $this->RenderText('Tipo Accion'), $currentPageCaption == $this->RenderText('Tipo Accion'), false, $this->RenderText('Paramétricas')));
     if (GetCurrentUserGrantForDataSource('public.sga_tipo_bien')->HasViewGrant())
         $result->AddPage(new PageLink($this->RenderText('Tipo Bien'), 'tipo_bien.php', $this->RenderText('Tipo Bien'), $currentPageCaption == $this->RenderText('Tipo Bien'), false, $this->RenderText('Paramétricas')));
     if (GetCurrentUserGrantForDataSource('public.sga_periodicidad')->HasViewGrant())
         $result->AddPage(new PageLink($this->RenderText('Periodicidad'), 'periodicidad.php', $this->RenderText('Periodicidad'), $currentPageCaption == $this->RenderText('Periodicidad'), false, $this->RenderText('Paramétricas')));
     if (GetCurrentUserGrantForDataSource('public.sga_planta')->HasViewGrant())
         $result->AddPage(new PageLink($this->RenderText('Planta'), 'planta.php', $this->RenderText('Planta'), $currentPageCaption == $this->RenderText('Planta'), false, $this->RenderText('Paramétricas')));
     if (GetCurrentUserGrantForDataSource('public.sga_origen')->HasViewGrant())
         $result->AddPage(new PageLink($this->RenderText('Origen'), 'origen.php', $this->RenderText('Origen'), $currentPageCaption == $this->RenderText('Origen'), false, $this->RenderText('Paramétricas')));
     if (GetCurrentUserGrantForDataSource('public.sga_tipo_espacio')->HasViewGrant())
         $result->AddPage(new PageLink($this->RenderText('Tipo Espacio'), 'tipo_espacio.php', $this->RenderText('Tipo Espacio'), $currentPageCaption == $this->RenderText('Tipo Espacio'), false, $this->RenderText('Paramétricas')));
     
     if ( HasAdminPage() && GetApplication()->HasAdminGrantForCurrentUser() ) {
       $result->AddGroup('Admin area');
       $result->AddPage(new PageLink($this->GetLocalizerCaptions()->GetMessageString('AdminPage'), 'phpgen_admin.php', $this->GetLocalizerCaptions()->GetMessageString('AdminPage'), false, false, 'Admin area'));
     }
     return $result;
 }
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     if (empty($args['s'])) {
         return '';
     }
     extract($args);
     $query = new TextSearchQuery($s, $case_exact, $regex);
     $pages = $dbi->fullSearch($query, $sortby, $limit, $exclude);
     $lines = array();
     $hilight_re = $hilight ? $query->getHighlightRegexp() : false;
     $count = 0;
     $found = 0;
     if ($quiet) {
         // see how easy it is with PageList...
         $list = new PageList(false, $exclude, $args);
         while ($page = $pages->next() and (!$limit or $count < $limit)) {
             $list->addPage($page);
         }
         return $list;
     }
     // Todo: we should better define a new PageListDL class for dl/dt/dd lists
     // But the new column types must have a callback then. (showhits)
     // See e.g. WikiAdminSearchReplace for custom pagelist columns
     $list = HTML::dl();
     if (!$limit or !is_int($limit)) {
         $limit = 0;
     }
     // expand all page wildcards to a list of pages which should be ignored
     if ($exclude) {
         $exclude = explodePageList($exclude);
     }
     while ($page = $pages->next() and (!$limit or $count < $limit)) {
         $name = $page->getName();
         if ($exclude and in_array($name, $exclude)) {
             continue;
         }
         $count++;
         $list->pushContent(HTML::dt(WikiLink($name)));
         if ($hilight_re) {
             $list->pushContent($this->showhits($page, $hilight_re));
         }
         unset($page);
     }
     if ($limit and $count >= $limit) {
         //todo: pager link to list of next matches
         $list->pushContent(HTML::dd(fmt("only %d pages displayed", $limit)));
     }
     if (!$list->getContent()) {
         $list->pushContent(HTML::dd(_("<no matches>")));
     }
     if (!empty($pages->stoplisted)) {
         $list = HTML(HTML::p(fmt(_("Ignored stoplist words '%s'"), join(', ', $pages->stoplisted))), $list);
     }
     if ($noheader) {
         return $list;
     }
     return HTML(HTML::p(fmt("Full text search results for '%s'", $s)), $list);
 }
 public function run()
 {
     //$u = new User();
     //if(!$u->isSuperUser()) { die(t("Access Denied."));} // cheap security check...
     $cfg = new Config();
     Loader::model('page_list');
     $pl = new PageList();
     //$pl->ignorePermissions();
     $pNum = $cfg->get('OLD_VERSION_JOB_PAGE_NUM');
     if ($pNum <= 0) {
         $cfg->save('OLD_VERSION_JOB_PAGE_NUM', 0);
     }
     $pl->setItemsPerPage(3);
     /* probably want to keep a record of pages that have been gone through 
      * so you don't start from the beginning each time..
      */
     $pNum = $pNum + 1;
     $pages = $pl->getPage($pNum);
     $cfg->save('OLD_VERSION_JOB_PAGE_NUM', $pNum);
     $pageCount = 0;
     $versionCount = 0;
     if (count($pages) == 0) {
         $cfg->save('OLD_VERSION_JOB_PAGE_NUM', 0);
         return t("All pages have been processes, starting from beginning on next run.");
     }
     foreach ($pages as $page) {
         if ($page instanceof Page) {
             $pvl = new VersionList($page);
             $versions = $pvl->getVersionListArray();
             $versions = array_reverse($versions);
             $vCount = count($versions);
             if ($vCount <= 10) {
                 continue;
             }
             $pageCount++;
             $stopAt = $vCount - 10;
             $i = 0;
             foreach ($versions as $v) {
                 if ($v instanceof CollectionVersion) {
                     if ($v->isApproved() || $v->isMostRecent()) {
                         // may want to add a date check here too
                         continue;
                     } else {
                         @$v->delete();
                         $versionCount++;
                     }
                 }
                 $i++;
                 if ($i >= $stopAt) {
                     break;
                 }
             }
         }
     }
     $pages = $pageCount == 1 ? t("Page") : t("Pages");
     return $versionCount . " " . t("versions deleted from") . " " . $pageCount . " " . $pages . " (" . $pNum . ")";
 }
Exemple #11
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     $pagelist = new PageList($info, $exclude, $args);
     // should attributes be listed as pagename here?
     $pagelist->addPageList($dbi->listRelations($mode == 'all', $mode == 'attributes', !empty($sortby)));
     return $pagelist;
 }
 function getPages($query = null)
 {
     Loader::model('page_list');
     $db = Loader::db();
     $bID = $this->bID;
     if ($this->bID) {
         $q = "select * from btDateNav where bID = '{$bID}'";
         $r = $db->query($q);
         if ($r) {
             $row = $r->fetchRow();
         }
     } else {
         $row['num'] = $this->num;
         $row['cParentID'] = $this->cParentID;
         $row['cThis'] = $this->cThis;
         $row['orderBy'] = $this->orderBy;
         $row['ctID'] = $this->ctID;
         $row['rss'] = $this->rss;
     }
     $pl = new PageList();
     $pl->setNameSpace('b' . $this->bID);
     $cArray = array();
     //$pl->sortByPublicDate();
     $pl->sortByPublicDateDescending();
     $num = (int) $row['num'];
     if ($num > 0) {
         $pl->setItemsPerPage($num);
     }
     $c = $this->getCollectionObject();
     if (is_object($c)) {
         $this->cID = $c->getCollectionID();
     }
     $cParentID = $row['cThis'] ? $this->cID : $row['cParentID'];
     if ($this->displayFeaturedOnly == 1) {
         Loader::model('attribute/categories/collection');
         $cak = CollectionAttributeKey::getByHandle('is_featured');
         if (is_object($cak)) {
             $pl->filterByIsFeatured(1);
         }
     }
     $pl->filter('cvName', '', '!=');
     if ($row['ctID']) {
         $pl->filterByCollectionTypeID($row['ctID']);
     }
     $pl->filterByAttribute('exclude_nav', false);
     if ($row['cParentID'] != 0) {
         $pl->filterByParentID($cParentID);
     }
     if ($num > 0) {
         $pages = $pl->getPage();
     } else {
         $pages = $pl->get();
     }
     $this->set('pl', $pl);
     return $pages;
 }
 public function sitemap()
 {
     global $varChecker;
     $drag = $varChecker->getValue('drag');
     $noDrag = $drag == 'false' ? 'true' : 'false';
     $site = $this->INK_User->getCustomer()->getSite();
     $menu = new PageList(array('id' => 'sitemap'), array('noDrag' => $noDrag));
     $this->pixelcms->siteName = $site->getName();
     $this->pixelcms->sitemap = $menu->getList();
 }
Exemple #14
0
 public function GetPageList()
 {
     $currentPageCaption = $this->GetShortCaption();
     $result = new PageList($this);
     if (GetCurrentUserGrantForDataSource('hometext')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Home Page Text'), 'HomePageText.php', $this->RenderText('Home Page Text'), $currentPageCaption == $this->RenderText('Home Page Text')));
     }
     if (HasAdminPage() && GetApplication()->HasAdminGrantForCurrentUser()) {
         $result->AddPage(new PageLink($this->GetLocalizerCaptions()->GetMessageString('AdminPage'), 'phpgen_admin.php', $this->GetLocalizerCaptions()->GetMessageString('AdminPage'), false, true));
     }
     return $result;
 }
 public function run()
 {
     $pl = new PageList();
     $pl->filterByCollectionTypeHandle('walk');
     $pl->filterByName('', true);
     $pages = $pl->get();
     $pagecount = count($pages);
     foreach ($pages as $page) {
         $page->moveToTrash();
     }
     return $pagecount . ' ' . t2('page', 'pages', $pagecount) . ' moved to the trash';
 }
Exemple #16
0
 protected function loadNewsSections()
 {
     $newsSectionList = new PageList();
     $newsSectionList->filterByEasynewsSection(1);
     $newsSectionList->sortBy('cvName', 'asc');
     $tmpSections = $newsSectionList->get();
     $sections = array();
     foreach ($tmpSections as $_c) {
         $sections[$_c->getCollectionID()] = $_c->getCollectionName();
     }
     $this->set('sections', $sections);
 }
 function populate()
 {
     $pl = new PageList('companies_added_today');
     $companies_do = new CompanyCollection(new Company());
     $sh = new SearchHandler($companies_do, false);
     $sh->extract();
     $sh->addConstraint(new Constraint('is_lead', '=', 'false'));
     $sh->addConstraint(new Constraint('created', '>', fix_date(date(DATE_FORMAT))));
     $sh->setLimit(10);
     $companies_do->load($sh);
     $pl->addFromCollection($companies_do, array('module' => 'contacts', 'controller' => 'companys', 'action' => 'view'), array('id'), 'company', 'name');
     $this->contents = $pl->getPages()->toArray();
 }
Exemple #18
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     // fix deprecated arg
     if (is_integer($pages)) {
         $numpages = $pages;
         $pages = false;
         // fix new pages handling in arg preprozessor.
     } elseif (is_array($pages)) {
         $numpages = (int) $pages[0];
         if ($numpages > 0 and !$dbi->isWikiPage($numpages)) {
             $pages = false;
         } else {
             $numpages = 1;
         }
     }
     $allpages = $dbi->getAllPages(false, $sortby, $limit, $exclude);
     $pagearray = $allpages->asArray();
     better_srand();
     // Start with a good seed.
     if ($numpages == 1 && $pagearray) {
         $page = $pagearray[array_rand($pagearray)];
         $pagename = $page->getName();
         if ($redirect) {
             $request->redirect(WikiURL($pagename, false, 'absurl'));
         }
         // noreturn
         if ($hidename) {
             return WikiLink($pagename, false, _("RandomPage"));
         } else {
             return WikiLink($pagename);
         }
     }
     $numpages = min(max(1, (int) $numpages), 20, count($pagearray));
     $pagelist = new PageList($info, $exclude, $args);
     $shuffle = array_rand($pagearray, $numpages);
     if (is_array($shuffle)) {
         foreach ($shuffle as $i) {
             if (isset($pagearray[$i])) {
                 $pagelist->addPage($pagearray[$i]);
             }
         }
     } else {
         // if $numpages = 1
         if (isset($pagearray[$shuffle])) {
             $pagelist->addPage($pagearray[$shuffle]);
         }
     }
     return $pagelist;
 }
 function populate()
 {
     $pl = new PageList('open_opportunities');
     $open_opportunities = new OpportunityCollection(new Opportunity());
     $sh = new SearchHandler($open_opportunities, false);
     $sh->extract();
     $sh->addConstraint(new Constraint('owner', '=', EGS_USERNAME));
     $sh->addConstraint(new Constraint('open', '=', 'true'));
     $sh->setLimit(10);
     $sh->setOrderBy('cost', 'DESC');
     $open_opportunities->load($sh);
     $pl->addFromCollection($open_opportunities, array('module' => 'crm', 'controller' => 'opportunitys', 'action' => 'view'), array('id'), 'opportunity', 'name');
     $this->setData($pl->getPages()->toArray());
 }
Exemple #20
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if (empty($page) && empty($prefix) && empty($suffix)) {
         return '';
     }
     if ($prefix) {
         $suffix = false;
         $descrip = fmt("Page names with prefix '%s'", $prefix);
     } elseif ($suffix) {
         $descrip = fmt("Page names with suffix '%s'", $suffix);
     } elseif ($page) {
         $words = preg_split('/[\\s:-;.,]+/', SplitPagename($page));
         $words = preg_grep('/\\S/', $words);
         $prefix = reset($words);
         $suffix = end($words);
         $descrip = fmt("These pages share an initial or final title word with '%s'", WikiLink($page, 'auto'));
     }
     // Search for pages containing either the suffix or the prefix.
     $search = $match = array();
     if (!empty($prefix)) {
         $search[] = $this->_quote($prefix);
         $match[] = '^' . preg_quote($prefix, '/');
     }
     if (!empty($suffix)) {
         $search[] = $this->_quote($suffix);
         $match[] = preg_quote($suffix, '/') . '$';
     }
     if ($search) {
         $query = new TextSearchQuery(join(' OR ', $search));
     } else {
         $query = new NullTextSearchQuery();
     }
     // matches nothing
     $match_re = '/' . join('|', $match) . '/';
     $pagelist = new PageList($info, $exclude, $args);
     if (!$noheader) {
         $pagelist->setCaption($descrip);
     }
     $pages = $dbi->titleSearch($query);
     while ($page = $pages->next()) {
         $name = $page->getName();
         if (!preg_match($match_re, $name)) {
             continue;
         }
         $pagelist->addPage($page);
     }
     return $pagelist;
 }
Exemple #21
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     if ($args['basepage']) {
         $pagename = $args['basepage'];
     } else {
         $pagename = $request->getArg('pagename');
     }
     // FIXME: explodePageList from stdlib doesn't seem to work as
     // expected when there are no subpages. (see also
     // UnfoldSubPages plugin)
     $subpages = explodePageList($pagename . SUBPAGE_SEPARATOR . '*');
     if (!$subpages) {
         return $this->error(_("The current page has no subpages defined."));
     }
     extract($args);
     $content = HTML();
     $subpages = array_reverse($subpages);
     if ($maxpages) {
         $subpages = array_slice($subpages, 0, $maxpages);
     }
     $descrip = fmt("SubPages of %s:", WikiLink($pagename, 'auto'));
     if ($info) {
         $info = explode(",", $info);
         if (in_array('count', $info)) {
             $args['types']['count'] = new _PageList_Column_ListSubpages_count('count', _("#"), 'center');
         }
     }
     $pagelist = new PageList($info, $exclude, $args);
     if (!$noheader) {
         $pagelist->setCaption($descrip);
     }
     foreach ($subpages as $page) {
         // A page cannot include itself. Avoid doublettes.
         static $included_pages = array();
         if (in_array($page, $included_pages)) {
             $content->pushContent(HTML::p(sprintf(_("recursive inclusion of page %s ignored"), $page)));
             continue;
         }
         array_push($included_pages, $page);
         //if ($relative) {
         // TODO: add relative subpage name display to PageList class
         //}
         $pagelist->addPage($page);
         array_pop($included_pages);
     }
     $content->pushContent($pagelist);
     return $content;
 }
 function populate()
 {
     $pl = new PageList('current_activities');
     $current_activities = new ActivityCollection(new Activity());
     $sh = new SearchHandler($current_activities, false);
     $sh->extract();
     $sh->addConstraint(new Constraint('assigned', '=', EGS_USERNAME));
     $sh->addConstraint(new Constraint('completed', 'IS', 'NULL'));
     $sh->addConstraint(new Constraint('startdate', '<', '(now())'));
     $sh->setLimit(10);
     $sh->setOrderBy('created', 'DESC');
     $current_activities->load($sh);
     $pl->addFromCollection($current_activities, array('module' => 'crm', 'controller' => 'activitys', 'action' => 'view'), array('id'), 'activity', 'name');
     $this->contents = $pl->getPages()->toArray();
 }
Exemple #23
0
 /**
  * Preselect a list of pagenames by the supporting the following args:
  * 's': comma-seperated list of pagename wildcards
  * 'author', 'owner', 'creator': from WikiDB_Page
  * 'only: forgot what the difference to 's' was.
  * Sets $this->_list, which is picked up by collectPages() and is a default for p[]
  */
 function preSelectS(&$args, &$request)
 {
     // override plugin argument by GET: probably not needed if s||="" is used
     // anyway, we force it for unique interface.
     if (!empty($request->getArg['s'])) {
         $args['s'] = $request->getArg['s'];
     }
     if (!empty($args['owner'])) {
         $sl = PageList::allPagesByOwner($args['owner'], false, $args['sortby'], $args['limit'], $args['exclude']);
     } elseif (!empty($args['author'])) {
         $sl = PageList::allPagesByAuthor($args['author'], false, $args['sortby'], $args['limit'], $args['exclude']);
     } elseif (!empty($args['creator'])) {
         $sl = PageList::allPagesByCreator($args['creator'], false, $args['sortby'], $args['limit'], $args['exclude']);
     } elseif (!empty($args['s']) or !empty($args['only'])) {
         // all pages by name
         $sl = explodePageList(empty($args['only']) ? $args['s'] : $args['only']);
     }
     $this->_list = array();
     if (!empty($sl)) {
         $request->setArg('verify', 1);
         foreach ($sl as $name) {
             if (!empty($args['exclude'])) {
                 if (!in_array($name, $args['exclude'])) {
                     $this->_list[$name] = 1;
                 }
             } else {
                 $this->_list[$name] = 1;
             }
         }
     }
     return $this->_list;
 }
 function populate()
 {
     if (!$this->isCached()) {
         $pl = new PageList('recently_added_leads');
         $companies_do = new CompanyCollection(new Company());
         $sh = new SearchHandler($companies_do, false);
         $sh->extract();
         $sh->addConstraint(new Constraint('is_lead', '=', 'true'));
         $sh->setLimit(10);
         $sh->setOrderBy('created', 'DESC');
         $companies_do->load($sh);
         $pl->addFromCollection($companies_do, array('module' => 'contacts', 'controller' => 'companys', 'action' => 'view'), array('id'), 'company', 'name');
         $this->setCache($pl->getPages()->toArray());
     }
     $this->contents = $this->getCache();
 }
 public function onLoad($param)
 {
     parent::onLoad($param);
     if (!$this->IsPostBack) {
         $FilterEmployee = $this->Session[$this->getApplication()->getService()->getRequestedPagePath() . 'FilterEmployee'];
         if ($FilterEmployee) {
             $this->FilterEmployee->Text = $FilterEmployee;
         }
         $FilterDepartment = $this->Session[$this->getApplication()->getService()->getRequestedPagePath() . 'FilterDepartment'];
         $this->FilterDepartment->DataSource = $this->DepartmentList;
         $this->FilterDepartment->dataBind();
         if ($FilterDepartment) {
             $this->FilterDepartment->setSelectedValue($FilterDepartment);
         } else {
             $this->FilterDepartment->setSelectedIndex(0);
         }
         $this->DataGrid->DataSource = $this->Data;
         $this->DataGrid->dataBind();
     }
     if (isset($this->Request['okMsg'])) {
         $this->displayMessage($this->Request['okMsg'], true);
     }
     if (isset($this->Request['koMsg'])) {
         $this->displayMessage($this->Request['koMsg'], false);
     }
 }
 public function onLoad($param)
 {
     parent::onLoad($param);
     $app = $this->getApplication();
     $usedId = $app->getUser()->getUserID() == null ? 0 : $app->getUser()->getUserID();
     $cmd = $this->db->createCommand("SELECT user_id FROM hr_superusers WHERE id={$usedId}");
     $data = $cmd->query();
     $dataUser = $data->read();
     $this->userId = $dataUser['user_id'];
     $this->employee = new employee($this->userId);
     $this->tbb->setTitle(Prado::localize("Leave request") . " - " . $this->employee->getFullName());
     if (!$this->IsPostBack) {
         if (Prado::getApplication()->getSession()->contains($this->getApplication()->getService()->getRequestedPagePath() . 'FilterState')) {
             $FilterState = $this->Session[$this->getApplication()->getService()->getRequestedPagePath() . 'FilterState'];
         } else {
             $FilterState = 'all';
         }
         $this->FilterState->setSelectedValue($FilterState);
         $this->DataGrid->DataSource = $this->Data;
         $this->DataGrid->dataBind();
     }
     if (isset($this->Request['okMsg'])) {
         $this->displayMessage($this->Request['okMsg'], true);
     }
     if (isset($this->Request['koMsg'])) {
         $this->displayMessage($this->Request['koMsg'], false);
     }
 }
 protected function onPrint()
 {
     parent::onPrint();
     $cellHeaderWidth = 6;
     $cellHeaderHeight = 20;
     $this->pdf->AddPage();
     $this->pdf->SetFont('Arial', '', 11);
     $this->pdf->Cell(0, 10, utf8_decode(Prado::localize('List of the users groups')), 0, 0, 'L');
     $this->pdf->Ln(10);
     $this->pdf->setDefaultFont();
     $groups = $this->getData();
     foreach ($groups as $ot) {
         $this->pdf->SetTextColor(0);
         $this->pdf->SetDrawColor(0);
         $this->pdf->SetFont('Arial', 'B', 11);
         $this->pdf->SetLineWidth(0.4);
         $this->pdf->Cell(0, 6, utf8_decode($ot['name']), 'B', 1, 'L');
         $this->pdf->setDefaultFont();
         $this->pdf->SetLineWidth(0.1);
         $this->pdf->SetDrawColor(127);
         $this->pdf->Cell(60, 6, utf8_decode(Prado::localize('Access plugin')), 'B', 0, 'L');
         $this->pdf->Cell(0, 6, utf8_decode($ot['accessPlugin']), 'B', 1, 'L');
         $this->pdf->Cell(60, 6, utf8_decode(Prado::localize('Description')), 'B', 0, 'L');
         $this->pdf->Cell(0, 6, utf8_decode($ot['comment']), 'B', 1, 'L');
         $command = $this->db->createCommand("SELECT * FROM hr_device WHERE accessPoint>0");
         $dataReader = $command->query();
         $this->pdf->Ln(5);
         $this->pdf->setDefaultFont();
         //! put a marge
         $this->pdf->Cell(30);
         $this->pdf->SetFillColor(124, 124, 124);
         $this->pdf->SetTextColor(255);
         $this->pdf->SetDrawColor(255);
         $this->pdf->SetLineWidth(0.3);
         $nEntry = array();
         foreach ($dataReader as $device) {
             $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode($device['name']), 1, 0, 'D', true);
             $nEntry[] = $device['id'];
         }
         $this->pdf->Ln($cellHeaderHeight);
         $command = $this->db->createCommand("SELECT * FROM hr_access_level");
         $dataAccess = $command->query();
         foreach ($dataAccess as $access) {
             $this->pdf->Cell(30, $cellHeaderWidth, utf8_decode($access['name']), 1, 0, 'L', true);
             for ($i = 0; $i < count($nEntry); $i++) {
                 $cmd = $this->db->createCommand("SELECT * FROM hr_user_group_access WHERE id_access_level=" . $access['id'] . " AND id_device=" . $nEntry[$i] . " AND id_group=" . $ot['id']);
                 $data = $cmd->query();
                 $data = $data->readAll();
                 if ($data) {
                     $this->pdf->Image("./fpdf/ok.png", $this->pdf->GetX() + $i * 6 + 1.5, $this->pdf->GetY() + 1.5, 3, 3);
                 } else {
                     $this->pdf->Image("./fpdf/ko.png", $this->pdf->GetX() + $i * 6 + 1.5, $this->pdf->GetY() + 1.5, 3, 3);
                 }
             }
             $this->pdf->Ln(6);
         }
         $this->pdf->Ln(10);
     }
     $this->pdf->render();
 }
 public function GetPageList()
 {
     $currentPageCaption = $this->GetShortCaption();
     $result = new PageList($this);
     $result->AddGroup('Default');
     if (GetCurrentUserGrantForDataSource('Dashboard')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Dashboard'), 'Dashboard.php', $this->RenderText('Dashboard'), $currentPageCaption == $this->RenderText('Dashboard'), false, 'Default'));
     }
     if (GetCurrentUserGrantForDataSource('program')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Project Type'), 'program.php', $this->RenderText('Project Type'), $currentPageCaption == $this->RenderText('Project Type'), false, 'Default'));
     }
     if (GetCurrentUserGrantForDataSource('project')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Project'), 'project.php', $this->RenderText('Project'), $currentPageCaption == $this->RenderText('Project'), false, 'Default'));
     }
     if (GetCurrentUserGrantForDataSource('task')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Task'), 'task.php', $this->RenderText('Task'), $currentPageCaption == $this->RenderText('Task'), false, 'Default'));
     }
     if (GetCurrentUserGrantForDataSource('Hours per Project by user')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Hours per Project'), 'Hours per project by user.php', $this->RenderText('Hours per project'), $currentPageCaption == $this->RenderText('Hours per Project'), false, 'Default'));
     }
     if (GetCurrentUserGrantForDataSource('staff')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Staff'), 'staff.php', $this->RenderText('Staff'), $currentPageCaption == $this->RenderText('Staff'), false, 'Default'));
     }
     if (GetCurrentUserGrantForDataSource('timesheet')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Time Tracking'), 'timesheet.php', $this->RenderText('Time Tracking'), $currentPageCaption == $this->RenderText('Time Tracking'), false, 'Default'));
     }
     if (GetCurrentUserGrantForDataSource('Priority')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Priority'), 'Priority.php', $this->RenderText('Priority'), $currentPageCaption == $this->RenderText('Priority'), false, 'Default'));
     }
     if (GetCurrentUserGrantForDataSource('task_names')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Task Names'), 'task_names.php', $this->RenderText('Task Names'), $currentPageCaption == $this->RenderText('Task Names'), false, 'Default'));
     }
     if (GetCurrentUserGrantForDataSource('Pay Period')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Pay Period'), 'Pay_Period.php', $this->RenderText('Pay Period'), $currentPageCaption == $this->RenderText('Pay Period'), false, 'Default'));
     }
     if (GetCurrentUserGrantForDataSource('department_projects')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Department Projects'), 'department_projects.php', $this->RenderText('Department Projects'), $currentPageCaption == $this->RenderText('Department Projects'), false, 'Default'));
     }
     if (GetCurrentUserGrantForDataSource('department')->HasViewGrant()) {
         $result->AddPage(new PageLink($this->RenderText('Department'), 'department.php', $this->RenderText('Department'), $currentPageCaption == $this->RenderText('Department'), false, 'Default'));
     }
     if (HasAdminPage() && GetApplication()->HasAdminGrantForCurrentUser()) {
         $result->AddGroup('Admin area');
         $result->AddPage(new PageLink($this->GetLocalizerCaptions()->GetMessageString('AdminPage'), 'phpgen_admin.php', $this->GetLocalizerCaptions()->GetMessageString('AdminPage'), false, false, 'Admin area'));
     }
     return $result;
 }
Exemple #29
0
 public function onLoad($param)
 {
     parent::onLoad($param);
     if (!$this->IsPostBack) {
         $this->DataGrid->DataSource = $this->Data;
         $this->DataGrid->dataBind();
     }
 }
 function populate()
 {
     $pl = new PageList('my_tickets');
     $my_tickets = new TicketCollection(new Ticket());
     $sh = new SearchHandler($my_tickets, false);
     $sh->extract();
     $sh->addConstraint(new Constraint('assigned_to', 'IS', 'NULL'));
     $cc = new ConstraintChain();
     $cc->add(new Constraint('internal_status_code', '=', 'NEW'), 'OR');
     $cc->add(new Constraint('internal_status_code', '=', 'OPEN'), 'OR');
     $sh->addConstraintChain($cc);
     $sh->setLimit(10);
     $sh->setOrderBy('created', 'DESC');
     $my_tickets->load($sh);
     $pl->addFromCollection($my_tickets, array('module' => 'ticketing', 'controller' => 'tickets', 'action' => 'view'), array('id'), 'ticket', 'summary');
     $this->contents = $pl->getPages()->toArray();
 }