Exemplo n.º 1
0
 /**
  * Show a form for editing an entry
  *
  * @return  void
  */
 public function editTask()
 {
     // Check if they're logged in
     if (User::isGuest()) {
         $this->loginTask();
         return;
     }
     // Check if admin
     $isAdmin = false;
     if (User::authorise('core.manage', $this->_option)) {
         $isAdmin = true;
     }
     // are we allowing user to add citation
     $allowImport = $this->config->get('citation_import', 1);
     if ($allowImport == 0 || $allowImport == 2 && User::get('usertype') == 'Super Administrator') {
         // Redirect
         App::redirect(Route::url('index.php?option=' . $this->_option, false), Lang::txt('COM_CITATION_EDIT_NOTALLOWED'), 'warning');
         return;
     }
     // get the citation types
     $ct = new Type($this->database);
     $types = $ct->getType();
     $fields = array();
     foreach ($types as $type) {
         if (isset($type['fields'])) {
             $f = $type['fields'];
             if (strpos($f, ',') !== false) {
                 $f = str_replace(',', "\n", $f);
             }
             $f = array_map('trim', explode("\n", $f));
             $f = array_values(array_filter($f));
             $fields[strtolower(str_replace(' ', '', $type['type_title']))] = $f;
         }
     }
     // add an empty value for the first type
     array_unshift($types, array('type' => '', 'type_title' => ' - Select a Type —'));
     // Incoming - expecting an array id[]=4232
     $id = Request::getInt('id', 0);
     // Pub author
     $pubAuthor = false;
     // Load the associations object
     $assoc = new Association($this->database);
     // Get associations
     if ($id) {
         $this->view->assocs = $assoc->getRecords(array('cid' => $id), $isAdmin);
         $pubAuthor = $this->isPubAuthor($this->view->assocs);
     }
     // Is user authorized to edit citations?
     if (!$isAdmin && !$pubAuthor) {
         $id = 0;
     }
     // Load the object
     $this->view->row = new Citation($this->database);
     $this->view->row->load($id);
     //make sure title isnt too long
     $maxTitleLength = 30;
     $shortenedTitle = strlen($this->view->row->title) > $maxTitleLength ? substr($this->view->row->title, 0, $maxTitleLength) . '…' : $this->view->row->title;
     // Set the pathway
     Pathway::append(Lang::txt(strtoupper($this->_option)), 'index.php?option=' . $this->_option);
     if ($id && $id != 0) {
         Pathway::append($shortenedTitle, 'index.php?option=' . $this->_option . '&task=view&id=' . $this->view->row->id);
     }
     Pathway::append(Lang::txt('COM_CITATIONS_EDIT'), 'index.php?option=' . $this->_option . '&task=edit&id=' . $this->view->row->id);
     // Set the page title
     Document::setTitle(Lang::txt('COM_CITATIONS_CITATION') . $shortenedTitle);
     //push jquery to doc
     Document::addScriptDeclaration('var fields = ' . json_encode($fields) . ';');
     // Instantiate a new view
     $this->view->title = Lang::txt(strtoupper($this->_option)) . ': ' . Lang::txt(strtoupper($this->_option) . '_' . strtoupper($this->_task));
     $this->view->config = $this->config;
     // No ID, so we're creating a new entry
     // Set the ID of the creator
     if (!$id) {
         $this->view->row->uid = User::get('id');
         // It's new - no associations to get
         $this->view->assocs = array();
         //tags & badges
         $this->view->tags = array();
         $this->view->badges = array();
     } else {
         //tags & badges
         $this->view->tags = Format::citationTags($this->view->row, $this->database, false);
         $this->view->badges = Format::citationBadges($this->view->row, $this->database, false);
     }
     //get the citation types
     $ct = new Type($this->database);
     $this->view->types = $ct->getType();
     // Output HTML
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     $this->view->setLayout('edit')->display();
 }
Exemplo n.º 2
0
</p>
									</div>
								<?php 
        }
        ?>

								<div class="citation-details">
									<?php 
        echo $formatter->citationDetails($cite, $this->database, $this->config, $this->openurl);
        ?>

									<?php 
        if ($this->config->get('citation_show_badges', 'no') == 'yes') {
            ?>
										<?php 
            echo \Components\Citations\Helpers\Format::citationBadges($cite, $this->database);
            ?>
									<?php 
        }
        ?>

									<?php 
        if ($this->config->get('citation_show_tags', 'no') == 'yes') {
            ?>
										<?php 
            echo \Components\Citations\Helpers\Format::citationTags($cite, $this->database);
            ?>
									<?php 
        }
        ?>
								</div>
Exemplo n.º 3
0
					</tr>
				<?php 
    }
    ?>

				<?php 
    if (is_array($badges) && count($badges) > 0 && $showBadges == 'yes') {
        ?>
					<tr>
						<th><?php 
        echo Lang::txt('COM_CITATIONS_BADGES');
        ?>
</th>
						<td>
							<?php 
        echo \Components\Citations\Helpers\Format::citationBadges($citation, App::get('db'));
        ?>
						</td>
					</tr>
				<?php 
    }
    ?>

				<?php 
    if (isset($citation->uid)) {
        ?>
					<?php 
        if (is_object($profile) && $profile->get('uidNumber')) {
            ?>
						<tr>
							<th><?php 
Exemplo n.º 4
0
 /**
  * Edit a citation
  *
  * @return	void
  */
 public function editTask()
 {
     //stop menu from working?
     Request::setVar('hidemainmenu', 1);
     //get request vars - expecting an array id[]=4232
     $id = Request::getVar('id', array());
     if (is_array($id)) {
         $id = !empty($id) ? $id[0] : 0;
     }
     //get all citations sponsors
     $cs = new Sponsor($this->database);
     $this->view->sponsors = $cs->getSponsor();
     //get all citation types
     $ct = new Type($this->database);
     $this->view->types = $ct->getType();
     //empty citation object
     $this->view->row = new Citation($this->database);
     //if we have an id load that citation data
     if (isset($id) && $id != '' && $id != 0) {
         // Load the citation object
         $this->view->row->load($id);
         // Get the associations
         $assoc = new Association($this->database);
         $this->view->assocs = $assoc->getRecords(array('cid' => $id));
         //get sponsors for citation
         $this->view->row_sponsors = $cs->getCitationSponsor($this->view->row->id);
         //get the citations tags
         $this->view->tags = Format::citationTags($this->view->row, \App::get('db'), false);
         //get the badges
         $this->view->badges = Format::citationBadges($this->view->row, \App::get('db'), false);
         //parse citation params
         $this->view->params = new Registry($this->view->row->params);
     } else {
         //set the creator
         $this->view->row->uid = User::get('id');
         // It's new - no associations to get
         $this->view->assocs = array();
         //array of sponsors - empty
         $this->view->row_sponsors = array();
         //empty tags and badges arrays
         $this->view->tags = array();
         $this->view->badges = array();
         //empty params object
         $this->view->params = new Registry('');
     }
     //are we padding back the citation data
     if (isset($this->row)) {
         $this->view->row = $this->row;
     }
     //are we passing back the tags from edit
     if ($this->tags != '') {
         $this->tags = explode(',', $this->tags);
         foreach ($this->tags as $tag) {
             $this->view->tags[]['raw_tag'] = $tag;
         }
     }
     //are we passing back the tags from edit
     if ($this->badges != '') {
         $this->badges = explode(',', $this->badges);
         foreach ($this->badges as $badge) {
             $this->view->badges[]['raw_tag'] = $badge;
         }
     }
     // Set any errors
     if ($this->getError()) {
         $this->view->setError($this->getError());
     }
     //set vars for view
     $this->view->config = $this->config;
     // Output the HTML
     $this->view->setLayout('edit')->display();
 }
Exemplo n.º 5
0
 /**
  * Display the form allowing to edit a citation
  *
  * @return  string  HTML
  */
 private function editAction($row = null)
 {
     // Check if they're logged in
     if (User::isGuest()) {
         return $this->loginAction();
     }
     if (!$this->params->get('access-manage')) {
         throw new Exception(Lang::txt('PLG_MEMBERS_CITATIONS_NOT_AUTHORIZED'), 403);
     }
     // Create view object
     $view = $this->view('edit');
     $view->member = $this->member;
     $view->option = $this->option;
     $view->database = $this->database;
     $view->allow_tags = $this->member->getParam('citation_allow_tags', 'yes');
     $view->allow_badges = $this->member->getParam('citatoin_allow_badges', 'yes');
     // Get the citation types
     $citationsType = \Components\Citations\Models\Type::all();
     $view->types = $citationsType->rows();
     $fields = array();
     foreach ($view->types as $type) {
         if (isset($type->fields)) {
             $f = $type->fields;
             if (strpos($f, ',') !== false) {
                 $f = str_replace(',', "\n", $f);
             }
             $f = array_map('trim', explode("\n", $f));
             $f = array_values(array_filter($f));
             $fields[strtolower(str_replace(' ', '', $type->type_title))] = $f;
         }
     }
     // Incoming
     $id = Request::getInt('cid', 0);
     // Load the object
     if (is_object($row)) {
         $view->row = $row;
     } else {
         $view->row = \Components\Citations\Models\Citation::oneOrNew($id);
         // check to see if this member created this citation
         if (!$view->row->isNew() && ($view->row->uid != User::get('id') || $view->row->scope != 'member')) {
             // redirect
             App::redirect(Route::url($this->member->getLink() . '&active=' . $this->_name), Lang::txt('PLG_MEMBERS_CITATIONS_OWNER_ONLY'), 'warning');
         }
     }
     //make sure title isnt too long
     $maxTitleLength = 30;
     $shortenedTitle = strlen($view->row->title) > $maxTitleLength ? substr($view->row->title, 0, $maxTitleLength) . '&hellip;' : $view->row->title;
     // Set the pathway
     if ($id && $id != 0) {
         Pathway::append($shortenedTitle, 'index.php?option=com_citations&task=view&id=' . $view->row->id);
         Pathway::append(Lang::txt('PLG_MEMBERS_CITATIONS_EDIT'));
     } else {
         Pathway::append(Lang::txt('PLG_MEMBERS_CITATIONS_ADD'));
     }
     // Set the page title
     Document::setTitle(Lang::txt('PLG_MEMBERS_CITATIONS_CITATION') . $shortenedTitle);
     //push jquery to doc
     Document::addScriptDeclaration('var fields = ' . json_encode($fields) . ';');
     // Instantiate a new view
     $view->title = Lang::txt('PLG_MEMBERS_CITATIONS') . ': ' . Lang::txt('PLG_MEMBERS_CITATIONS_' . strtoupper($this->action));
     // No ID, so we're creating a new entry
     // Set the ID of the creator
     if (!$id) {
         $view->row->uid = User::get('id');
         //tags & badges
         $view->tags = array();
         $view->badges = array();
         $view->row->id = -time();
     } else {
         if ($view->row->relatedAuthors->count()) {
             $view->authors = $view->row->relatedAuthors;
         } elseif ($view->row->relatedAuthors->count() == 0 && $view->row->author != '') {
             // formats the author for the multi-author plugin
             $authors = explode(';', $view->row->author);
             $authorString = '';
             $totalAuths = count($authors);
             $x = 0;
             foreach ($authors as &$author) {
                 /***
                  * Because the multi-select keys off of a comma,
                  * imported entries may display incorrectly (Wojkovich, Kevin) breaks the multi-select
                  * Convert this to Kevin Wojkovich and I'll @TODO add some logic in the formatter to
                  * format it properly within the bibilographic format ({LASTNAME},{FIRSTNAME})
                  ***/
                 $authorEntry = explode(',', $author);
                 if (count($authorEntry == 2)) {
                     $author = $authorEntry[1] . ' ' . $authorEntry[0];
                 }
                 $authorString .= $author;
                 if ($totalAuths > 1 && $x < $totalAuths - 1) {
                     $authorString .= ',';
                 }
                 $x = $x + 1;
             }
             $view->authorString = $authorString;
         }
         //tags & badges
         $view->tags = \Components\Citations\Helpers\Format::citationTags($view->row, $this->database, false);
         $view->badges = \Components\Citations\Helpers\Format::citationBadges($view->row, $this->database, false);
     }
     // Output HTML
     foreach ($this->getErrors() as $error) {
         $view->setError($error);
     }
     return $view->loadTemplate();
 }
Exemplo n.º 6
0
 /**
  * Display the form allowing to edit a citation
  *
  * @return		 string HTML
  */
 private function _edit()
 {
     // create view object
     $view = $this->view('default', 'edit');
     // Check if they're logged in
     if (User::isGuest()) {
         $this->_loginTask();
     }
     // push objects to view
     $view->group = $this->group;
     $view->isManager = $this->authorized == 'manager' ? true : false;
     $view->config = new \Hubzero\Config\Registry($this->group->get('params'));
     if ($view->isManager == false) {
         App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->cn . '&active=citations'), Lang::txt('PLG_GROUPS_CITATIONS_GROUP_MANAGER_ONLY'), 'warning');
     }
     // get the citation types
     $citationsType = \Components\Citations\Models\Type::all();
     $view->types = $citationsType->rows()->toObject();
     $fields = array();
     foreach ($view->types as $type) {
         if (isset($type->fields)) {
             $f = $type->fields;
             if (strpos($f, ',') !== false) {
                 $f = str_replace(',', "\n", $f);
             }
             $f = array_map('trim', explode("\n", $f));
             $f = array_values(array_filter($f));
             $fields[strtolower(str_replace(' ', '', $type->type_title))] = $f;
         }
     }
     // Incoming - expecting an array id[]=4232
     $id = Request::getInt('id', 0);
     // Pub author
     $pubAuthor = false;
     // Is user authorized to edit citations?
     if (!$view->isManager && !$pubAuthor) {
         $id = 0;
     }
     // Load the object
     $view->row = \Components\Citations\Models\Citation::oneorNew($id);
     // make sure title isnt too long
     $maxTitleLength = 30;
     $shortenedTitle = strlen($view->row->title) > $maxTitleLength ? substr($view->row->title, 0, $maxTitleLength) . '&hellip;' : $view->row->title;
     // Set the pathway
     if ($id && $id != 0) {
         Pathway::append($shortenedTitle, 'index.php?option=com_citations&task=view&id=' . $view->row->id);
         Pathway::append(Lang::txt('PLG_GROUPS_CITATIONS_EDIT'));
     } else {
         Pathway::append(Lang::txt('PLG_GROUPS_CITATIONS_ADD'));
     }
     // non-owner redirect
     if (!$view->row->isNew() && $view->row->scope != 'group') {
         App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->cn . '&active=citations'), Lang::txt('PLG_GROUPS_CITATIONS_PERMISSION_DENIED'), 'warning');
     }
     // Set the page title
     Document::setTitle(Lang::txt('PLG_GROUPS_CITATIONS_CITATION') . $shortenedTitle);
     // push jquery to doc
     Document::addScriptDeclaration('var fields = ' . json_encode($fields) . ';');
     // Instantiate a new view
     $view->title = Lang::txt(strtoupper($this->_name)) . ': ' . Lang::txt(strtoupper($this->_name) . '_' . strtoupper($this->action));
     // No ID, so we're creating a new entry
     // Set the ID of the creator
     if (!$id) {
         $view->row->uid = User::get('id');
         // tags & badges
         $view->tags = array();
         $view->badges = array();
         $view->row->id = -time();
     } else {
         if ($view->row->relatedAuthors->count()) {
             $view->authors = $view->row->relatedAuthors;
         } elseif ($view->row->relatedAuthors->count() == 0 && $view->row->author != '') {
             // formats the author for the multi-author plugin
             $authors = explode(';', $view->row->author);
             $authorString = '';
             $totalAuths = count($authors);
             $x = 0;
             foreach ($authors as &$author) {
                 /***
                  * Because the multi-select keys off of a comma,
                  * imported entries may display incorrectly (Wojkovich, Kevin) breaks the multi-select
                  * Convert this to Kevin Wojkovich and I'll @TODO add some logic in the formatter to
                  * format it properly within the bibilographic format ({LASTNAME},{FIRSTNAME})
                  ***/
                 $authorEntry = explode(',', $author);
                 if (count($authorEntry) == 2) {
                     $author = $authorEntry[1] . ' ' . $authorEntry[0];
                 }
                 $authorString .= $author;
                 if ($totalAuths > 1 && $x < $totalAuths - 1) {
                     $authorString .= ',';
                 }
                 $x = $x + 1;
             }
             $view->authorString = $authorString;
         }
         // tags & badges
         $view->tags = \Components\Citations\Helpers\Format::citationTags($view->row, $this->database, false);
         $view->badges = \Components\Citations\Helpers\Format::citationBadges($view->row, $this->database, false);
     }
     // Output HTML
     foreach ($this->getErrors() as $error) {
         $view->setError($error);
     }
     return $view->loadTemplate();
 }