コード例 #1
0
ファイル: nested.php プロジェクト: chaudhary4k4/modernstore
 /**
  * Overrides the automated table checks to handle the 'hash' column for faster searching
  *
  * @return boolean
  */
 public function check()
 {
     // Create a slug if there is a title and an empty slug
     if ($this->hasField('title') && $this->hasField('slug') && empty($this->slug)) {
         $this->slug = F0FStringUtils::toSlug($this->title);
     }
     // Create the SHA-1 hash of the slug for faster searching (make sure the hash column is CHAR(64) to take
     // advantage of MySQL's optimised searching for fixed size CHAR columns)
     if ($this->hasField('hash') && $this->hasField('slug')) {
         $this->hash = sha1($this->slug);
     }
     // Reset cached values
     $this->resetTreeCache();
     return parent::check();
 }
コード例 #2
0
 /**
  * Get the field configuration
  *
  * @return  array
  */
 protected function getConfig()
 {
     // If no custom options were defined let's figure out which ones of the
     // defaults we shall use...
     $config = array('published' => 1, 'unpublished' => 1, 'archived' => 0, 'trash' => 0, 'all' => 0);
     $stack = array();
     if (isset($this->element['show_published'])) {
         $config['published'] = F0FStringUtils::toBool($this->element['show_published']);
     }
     if (isset($this->element['show_unpublished'])) {
         $config['unpublished'] = F0FStringUtils::toBool($this->element['show_unpublished']);
     }
     if (isset($this->element['show_archived'])) {
         $config['archived'] = F0FStringUtils::toBool($this->element['show_archived']);
     }
     if (isset($this->element['show_trash'])) {
         $config['trash'] = F0FStringUtils::toBool($this->element['show_trash']);
     }
     if (isset($this->element['show_all'])) {
         $config['all'] = F0FStringUtils::toBool($this->element['show_all']);
     }
     return $config;
 }
コード例 #3
0
ファイル: toolbar.php プロジェクト: ppantilla/bbninja
 /**
  * Render a toolbar element.
  *
  * @param   string  $type        The element type.
  * @param   mixed   $value       The element value.
  * @param   array   $attributes  The element attributes.
  *
  * @return  void
  *
  * @codeCoverageIgnore
  * @throws  InvalidArgumentException
  */
 private function renderToolbarElement($type, $value = null, array $attributes = array())
 {
     switch ($type) {
         case 'title':
             $icon = isset($attributes['icon']) ? $attributes['icon'] : 'generic.png';
             JToolbarHelper::title($value, $icon);
             break;
         case 'divider':
             JToolbarHelper::divider();
             break;
         case 'custom':
             $task = isset($attributes['task']) ? $attributes['task'] : '';
             $icon = isset($attributes['icon']) ? $attributes['icon'] : '';
             $iconOver = isset($attributes['icon_over']) ? $attributes['icon_over'] : '';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : '';
             $listSelect = isset($attributes['list_select']) ? F0FStringUtils::toBool($attributes['list_select']) : true;
             JToolbarHelper::custom($task, $icon, $iconOver, $alt, $listSelect);
             break;
         case 'preview':
             $url = isset($attributes['url']) ? $attributes['url'] : '';
             $update_editors = isset($attributes['update_editors']) ? F0FStringUtils::toBool($attributes['update_editors']) : false;
             JToolbarHelper::preview($url, $update_editors);
             break;
         case 'help':
             if (!isset($attributes['help'])) {
                 throw new InvalidArgumentException('The help attribute is missing in the help button type.');
             }
             $ref = $attributes['help'];
             $com = isset($attributes['com']) ? F0FStringUtils::toBool($attributes['com']) : false;
             $override = isset($attributes['override']) ? $attributes['override'] : null;
             $component = isset($attributes['component']) ? $attributes['component'] : null;
             JToolbarHelper::help($ref, $com, $override, $component);
             break;
         case 'back':
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_BACK';
             $href = isset($attributes['href']) ? $attributes['href'] : 'javascript:history.back();';
             JToolbarHelper::back($alt, $href);
             break;
         case 'media_manager':
             $directory = isset($attributes['directory']) ? $attributes['directory'] : '';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_UPLOAD';
             JToolbarHelper::media_manager($directory, $alt);
             break;
         case 'assign':
             $task = isset($attributes['task']) ? $attributes['task'] : 'assign';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_ASSIGN';
             JToolbarHelper::assign($task, $alt);
             break;
         case 'new':
             if ($this->perms->create) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'add';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_NEW';
                 $check = isset($attributes['check']) ? F0FStringUtils::toBool($attributes['check']) : false;
                 JToolbarHelper::addNew($task, $alt, $check);
             }
             break;
         case 'publish':
             if ($this->perms->editstate) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'publish';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_PUBLISH';
                 $check = isset($attributes['check']) ? F0FStringUtils::toBool($attributes['check']) : false;
                 JToolbarHelper::publish($task, $alt, $check);
             }
             break;
         case 'publishList':
             if ($this->perms->editstate) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'publish';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_PUBLISH';
                 JToolbarHelper::publishList($task, $alt);
             }
             break;
         case 'unpublish':
             if ($this->perms->editstate) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'unpublish';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_UNPUBLISH';
                 $check = isset($attributes['check']) ? F0FStringUtils::toBool($attributes['check']) : false;
                 JToolbarHelper::unpublish($task, $alt, $check);
             }
             break;
         case 'unpublishList':
             if ($this->perms->editstate) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'unpublish';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_UNPUBLISH';
                 JToolbarHelper::unpublishList($task, $alt);
             }
             break;
         case 'archiveList':
             if ($this->perms->editstate) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'archive';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_ARCHIVE';
                 JToolbarHelper::archiveList($task, $alt);
             }
             break;
         case 'unarchiveList':
             if ($this->perms->editstate) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'unarchive';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_UNARCHIVE';
                 JToolbarHelper::unarchiveList($task, $alt);
             }
             break;
         case 'editList':
             if ($this->perms->edit) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'edit';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_EDIT';
                 JToolbarHelper::editList($task, $alt);
             }
             break;
         case 'editHtml':
             $task = isset($attributes['task']) ? $attributes['task'] : 'edit_source';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_EDIT_HTML';
             JToolbarHelper::editHtml($task, $alt);
             break;
         case 'editCss':
             $task = isset($attributes['task']) ? $attributes['task'] : 'edit_css';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_EDIT_CSS';
             JToolbarHelper::editCss($task, $alt);
             break;
         case 'deleteList':
             if ($this->perms->delete) {
                 $msg = isset($attributes['msg']) ? $attributes['msg'] : '';
                 $task = isset($attributes['task']) ? $attributes['task'] : 'remove';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_DELETE';
                 JToolbarHelper::deleteList($msg, $task, $alt);
             }
             break;
         case 'trash':
             if ($this->perms->editstate) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'remove';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_TRASH';
                 $check = isset($attributes['check']) ? F0FStringUtils::toBool($attributes['check']) : true;
                 JToolbarHelper::trash($task, $alt, $check);
             }
             break;
         case 'apply':
             $task = isset($attributes['task']) ? $attributes['task'] : 'apply';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_APPLY';
             JToolbarHelper::apply($task, $alt);
             break;
         case 'save':
             $task = isset($attributes['task']) ? $attributes['task'] : 'save';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_SAVE';
             JToolbarHelper::save($task, $alt);
             break;
         case 'save2new':
             $task = isset($attributes['task']) ? $attributes['task'] : 'save2new';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_SAVE_AND_NEW';
             JToolbarHelper::save2new($task, $alt);
             break;
         case 'save2copy':
             $task = isset($attributes['task']) ? $attributes['task'] : 'save2copy';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_SAVE_AS_COPY';
             JToolbarHelper::save2copy($task, $alt);
             break;
         case 'checkin':
             $task = isset($attributes['task']) ? $attributes['task'] : 'checkin';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_CHECKIN';
             $check = isset($attributes['check']) ? F0FStringUtils::toBool($attributes['check']) : true;
             JToolbarHelper::checkin($task, $alt, $check);
             break;
         case 'cancel':
             $task = isset($attributes['task']) ? $attributes['task'] : 'cancel';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_CANCEL';
             JToolbarHelper::cancel($task, $alt);
             break;
         case 'preferences':
             if (!isset($attributes['component'])) {
                 throw new InvalidArgumentException('The component attribute is missing in the preferences button type.');
             }
             $component = $attributes['component'];
             $height = isset($attributes['height']) ? $attributes['height'] : '550';
             $width = isset($attributes['width']) ? $attributes['width'] : '875';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JToolbar_Options';
             $path = isset($attributes['path']) ? $attributes['path'] : '';
             JToolbarHelper::preferences($component, $height, $width, $alt, $path);
             break;
         default:
             throw new InvalidArgumentException(sprintf('Unknown button type %s', $type));
     }
 }
コード例 #4
0
ファイル: table.php プロジェクト: lyrasoft/lyrasoft.github.io
 /**
  * The event which runs before storing (saving) data to the database
  *
  * @param   boolean  $updateNulls  Should nulls be saved as nulls (true) or just skipped over (false)?
  *
  * @return  boolean  True to allow saving
  */
 protected function onBeforeStore($updateNulls)
 {
     // Do we have a "Created" set of fields?
     $created_on = $this->getColumnAlias('created_on');
     $created_by = $this->getColumnAlias('created_by');
     $modified_on = $this->getColumnAlias('modified_on');
     $modified_by = $this->getColumnAlias('modified_by');
     $locked_on = $this->getColumnAlias('locked_on');
     $locked_by = $this->getColumnAlias('locked_by');
     $title = $this->getColumnAlias('title');
     $slug = $this->getColumnAlias('slug');
     $hasCreatedOn = in_array($created_on, $this->getKnownFields());
     $hasCreatedBy = in_array($created_by, $this->getKnownFields());
     if ($hasCreatedOn && $hasCreatedBy) {
         $hasModifiedOn = in_array($modified_on, $this->getKnownFields());
         $hasModifiedBy = in_array($modified_by, $this->getKnownFields());
         $nullDate = $this->_db->getNullDate();
         if (empty($this->{$created_by}) || $this->{$created_on} == $nullDate || empty($this->{$created_on})) {
             $uid = F0FPlatform::getInstance()->getUser()->id;
             if ($uid) {
                 $this->{$created_by} = F0FPlatform::getInstance()->getUser()->id;
             }
             $date = F0FPlatform::getInstance()->getDate('now', null, false);
             $this->{$created_on} = method_exists($date, 'toSql') ? $date->toSql() : $date->toMySQL();
         } elseif ($hasModifiedOn && $hasModifiedBy) {
             $uid = F0FPlatform::getInstance()->getUser()->id;
             if ($uid) {
                 $this->{$modified_by} = F0FPlatform::getInstance()->getUser()->id;
             }
             $date = F0FPlatform::getInstance()->getDate('now', null, false);
             $this->{$modified_on} = method_exists($date, 'toSql') ? $date->toSql() : $date->toMySQL();
         }
     }
     // Do we have a set of title and slug fields?
     $hasTitle = in_array($title, $this->getKnownFields());
     $hasSlug = in_array($slug, $this->getKnownFields());
     if ($hasTitle && $hasSlug) {
         if (empty($this->{$slug})) {
             // Create a slug from the title
             $this->{$slug} = F0FStringUtils::toSlug($this->{$title});
         } else {
             // Filter the slug for invalid characters
             $this->{$slug} = F0FStringUtils::toSlug($this->{$slug});
         }
         // Make sure we don't have a duplicate slug on this table
         $db = $this->getDbo();
         $query = $db->getQuery(true)->select($db->qn($slug))->from($this->_tbl)->where($db->qn($slug) . ' = ' . $db->q($this->{$slug}))->where('NOT ' . $db->qn($this->_tbl_key) . ' = ' . $db->q($this->{$this->_tbl_key}));
         $db->setQuery($query);
         $existingItems = $db->loadAssocList();
         $count = 0;
         $newSlug = $this->{$slug};
         while (!empty($existingItems)) {
             $count++;
             $newSlug = $this->{$slug} . '-' . $count;
             $query = $db->getQuery(true)->select($db->qn($slug))->from($this->_tbl)->where($db->qn($slug) . ' = ' . $db->q($newSlug))->where('NOT ' . $db->qn($this->_tbl_key) . ' = ' . $db->q($this->{$this->_tbl_key}));
             $db->setQuery($query);
             $existingItems = $db->loadAssocList();
         }
         $this->{$slug} = $newSlug;
     }
     // Call the behaviors
     $result = $this->tableDispatcher->trigger('onBeforeStore', array(&$this, $updateNulls));
     if (in_array(false, $result, true)) {
         // Behavior failed, return false
         return false;
     }
     // Execute onBeforeStore<tablename> events in loaded plugins
     if ($this->_trigger_events) {
         $name = F0FInflector::pluralize($this->getKeyName());
         $result = F0FPlatform::getInstance()->runPlugins('onBeforeStore' . ucfirst($name), array(&$this, $updateNulls));
         if (in_array(false, $result, true)) {
             return false;
         } else {
             return true;
         }
     }
     return true;
 }
コード例 #5
0
			<tr>
				<td colspan="11">
					<?php 
echo $this->pagination->getListFooter();
?>
</td>
			</tr>
		</tfoot>
		<tbody>
		<?php 
$i = 1;
foreach ($this->items as $profile) {
    $id = JHTML::_('grid.id', ++$i, $profile->id);
    $link = 'index.php?option=com_akeeba&amp;view=profiles&amp;task=edit&amp;id=' . $profile->id;
    $i = 1 - $i;
    $exportBaseName = F0FStringUtils::toSlug($profile->description);
    ?>
			<tr class="row<?php 
    echo $i;
    ?>
">
				<td><?php 
    echo $id;
    ?>
</td>
				<td><?php 
    echo $profile->id;
    ?>
</td>
				<td>
					<button class="btn btn-mini btn-primary" onclick="window.location='index.php?option=com_akeeba&task=switchprofile&profileid=<?php